1def prime(num):
2 if num>1:
3 s=int(num/2)
4 for i in range(2,s+1):
5 if num%i==0:
6 return("not prime")
7 break
8 return("prime")
9print(prime(239))
1import math
2a=[i for i in range(2,int(input('prime number range'))) if 0 not in [i%n for n in range(2,int(math.sqrt(i)))]]
3print(a)
1# Python program to display all the prime numbers within an interval
2
3lower = 900
4upper = 1000
5
6print("Prime numbers between", lower, "and", upper, "are:")
7
8for num in range(lower, upper + 1):
9 # all prime numbers are greater than 1
10 if num > 1:
11 for i in range(2, num):
12 if (num % i) == 0:
13 break
14 else:
15 print(num)Copied