1. Home
  2. Python
  3. Python Examples
  4. Python – Print All Prime Numbers

Python – Print All Prime Numbers

Python Program to Print All Prime Numbers

Q. Write a Python program to print all prime numbers between 1 and given number. Also write program to take input of two numbers and print prime numbers between them.

In our previous tutorial, you have learned to check if a number is prime number. You just need to use code inside a for loop.

Example:

A sample Python program to take input of maximum number and print all available prime numbers between 1 and given number.

Ouput:

Enter max number: 20
2
3
5
7
11
13
17
19

Another Example:

Another example to take input of minimum and maximum number. Then print all the prime numbers available between those numbers

Output:

Enter start number: 50
Enter end number: 100
53
59
61
67
71
73
79
83
89
97
Tags