Questions

How do you find the Prime Numbers from 1 to 100 in Python?

To find all the prime numbers that lie between an upper and lower limit, such as 1 and 100, these limits will need to be defined. A FOR loop will be used to calculate the Python prime numbers that make the code iterate till the upper limit is reached. A sample code is provided below.

                    

lower = 1

upper = 100

for num in range (lower, upper+1)

if num > 1:

              for i in range (2, num)

                             if (num % i) == 0

                                            break

                             else:

                                            print (num)

Related Questions

Related Topics

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.