1.

How to check the prime number in Python?

Answer»

Here's a program to check whether a number is prime or not.

Note: PYTHON is an interpreted bytecode-complied language. Our list of Python CODING Interview QUESTIONS will clear the basic as well as complex concepts of this high-level programming language.

Example

num = 11
if num > 1:     
   for i in range(2, num//2):

   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")
OUTPUT
11 is a prime number



Discussion

No Comment Found