# Python Program to print Prime numbers

In this post, I am going to write a simple Python 3 program to print the Prime numbers within a limit. Firstly, Let me explain what is a prime number.

If you don’t know what is a prime number, here is a small explanation:

1. 1 is divisible by itself only (divisible by 1 natural number, so not a prime number)
2. 2 is divisible by itself and also can be divisible by 1 (divisible by 2 natural numbers, so it a prime)
3. 3 is also divisible by itself and by 1 (divisible by 2 natural numbers, so it a prime)
4. But, 4 is divisible by itself as well as by 2 and by 1 (divisible by 3 natural numbers, so it is not a prime number)
5. 5 is divisible by itself and by 1 (divisible by 2 natural numbers, so it is a prime number)
6. 6 is divisible by itself and by 3 and by 2 and by 1 (so it is divisible by 4 natural numbers, so it is not a prime number)

Here is the Python function to print Prime numbers within a limit:

So basically you just have to call the print_prime() function pass the limit as an argument to the function to print the Prime numbers.

Here is the usage of the above function for you:

This above example snippet will ask you to first enter the limit, once it is entered then it will print the prime numbers for you.

This is the sample output of the above snippet:

I hope this post would have helped you to understand how to print Prime number using Python. Thanks for your time and welcome! 🙂

You can also check my previous post “Python program to find a number is a prime number or not!“.