Answer to Question #287928 in Python for Srinivas Thumma

Question #287928

2


6


7


9


5


Find the prime no.of range

1
Expert's answer
2022-01-17T00:34:46-0500
# Python program to check if given number is prime or not

num = int(input(" Please Enter any Number: "))

# If given number is greater than 1
if num > 1:
	# Iterate from 2 to n / 2
	for i in range(2, int(num/2)+1):
		# If num is divisible by any number between
		# 2 and n / 2, it is not prime
		if (num % i) == 0:
			print(num, "is not a prime number")
			break
	else:
		print(num, "is a prime number")
else:
	print(num, "is not a prime number")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS