Write a Python Program to Check Prime Number
Write a Python Program to Check Prime Number
A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. In other words we can say that a prime number is a natural number greater than 1 which are divided by 1 and itself. Smallest prime number is 2 (2 is the only even prime number).
For example
11 is a prime number as it is divided by 1 and itself.
23 is a prime number as it has only two factors (1 and 23.)
25 is not a prime number as it has more than 2 factors(1, 5 and 25)
Write a Program in Python to Check a number is prime or not.

OUTPUT

Explanation of above code
- Accept any number (say n1) from the user.
- If the number is greater than one(1), then we will check that whether this number is divisible by any other number between 2 and half of that number(n1) with the help of ‘for’ loop.
- If the above condition is true then we will display “It is a Prime number” otherwise we will display “It is not a prime number”
- If the number is less than one(1) then it is not a prime number.
Another way of writing the program

OUTPUT

MCQ of Computer Science Chapter Wise
2. Flow of Control (Loop and Conditional statement)
3. 140+ MCQ on Introduction to Python
4. 120 MCQ on String in Python
7. 100+ MCQ on Flow of Control in Python
8. 60+ MCQ on Dictionary in Python
Important Links
100 Practice Questions on Python Fundamentals
120+ MySQL Practice Questions
90+ Practice Questions on List
50+ Output based Practice Questions
100 Practice Questions on String
70 Practice Questions on Loops
70 Practice Questions on if-else
Disclaimer : I tried to give you the correct coding of ” Python Program to Check Prime Number” , but if you feel that there is/are mistakes in the code or explanation of “Python Program to Check Prime Number “ given above, you can directly contact me at csiplearninghub@gmail.com.