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))
1n = 20
2primes = []
3
4for i in range(2, n + 1):
5 for j in range(2, int(i ** 0.5) + 1):
6 if i%j == 0:
7 break
8 else:
9 primes.append(i)
10
11print(primes)
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
1#make the function
2#to do this all hte vairibles go in side the function
3
4def CheckIfPrime ():
5 a1 = input("which number do you want to check")
6 a = int(a1)#you need the checking number as an int not an str
7 b = 2 #the number to check againts
8 c = ("yes")
9 while b < a:#run the loop
10 if a%b == 0:#check if the division has a remainder
11 c = ("no")#set the answer
12 b = b+1
13 print(c)#print the output
14CheckIfPrime ()#call the function
15