- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

# Python program to print all Prime numbers in an Interval

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given an interval we need to compute all the prime numbers in a given range

Here we will be discussing a brute-force approach to get the solution i.e. the basic definition of a prime number. Prime numbers are the number which has 1 and itself as a factor and rests all the numbers are not its factors.

Each time the condition of a prime number is evaluated to be true computation is performed.

Now let’s observe the concept in the implementation below−

## Example

start = 1 end = 37 for val in range(start, end + 1): # If num is divisible by any number # between 2 and val, it is not prime if val > 1: for n in range(2, val): if (val % n) == 0: break else: print(val)

### Output

2 3 5 7 11 13 17 19 23 29 31 37

All the variables are declared in the local scope and their references are seen in the figure above.

## Conclusion

In this article, we have learned about how we can print all the prime numbers in an interval

- Related Articles
- How to Print all Prime Numbers in an Interval using Python?
- Python Program to Print Numbers in an Interval
- Program to find Prime Numbers Between given Interval in C++
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Program to count odd numbers in an interval range using Python
- Java program to print prime numbers below 100
- Python Program for Efficient program to print all prime factors of a given number
- How to identify and print all the perfect numbers in some closed interval [ 2, n ] using Python?
- Print prime numbers with prime sum of digits in an array
- Python program to print all Disarium numbers between 1 to 100
- Print all prime numbers less than or equal to N in C++
- Python program to print all Happy numbers between 1 and 100
- Print all Semi-Prime Numbers less than or equal to N in C++
- Python Program to print all distinct uncommon digits present in two given numbers