Write a program to check for prime number?



Write a program to check for prime number?..

Answer / Raisuddin Khan

Here is a simple way to check if a number is prime: def is_prime(n): if n <= 1: return False elif n <= 3: return True else: for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return Truennis_prime(7)

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

How does Python’s list.sort work at a high level? Is it stable? What’s the runtime?

1 Answers  


What is the language from which Python has got its features or derived its features?

1 Answers  


Can you hack with python?

1 Answers  


What is the use of dictionary in python?

1 Answers  


How many functions are in python?

1 Answers  


What is the use of ‘self’ keyword in python?

1 Answers  


What is data type set in python and how to work with it?

1 Answers  


Is java or python better?

1 Answers  


What can I create with python?

1 Answers  


Is python a single inheritance?

1 Answers  


What is singleton class in python?

1 Answers  


What does [::-1} do?

1 Answers  


Categories