Q:

How to Print Prime Number in Python?

0

Program to display the prime number in a given range.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Let's create a program to display the prime numbers in a given range:

low = int(input("Enter lower range: "))  
high = int(input("Enter upper range: "))  
  
for n in range(low,high + 1):  
   if n > 1:  
       for i in range(2,n):  
           if (n % i) == 0:  
               break  
       else:  
           print(n) 

Output:

Enter lower range: 5

Enter upper range: 50

5

7

11

13

17

19

23

29

31

37

41

43

47

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now