Program to find all even numbers within an interval in Python
In this python programming article, we are going to learn
python program to find even numbers in a given range
Program to find the even numbers within a range in Python
The python program to find even numbers in a given range is as follows:
# Owner : TutorialsInhand Author : Devjeet Roy
lower_limit = int(input("Enter lower limit: "))
upper_limit = int(input("Enter upper limit: "))
for i in range(lower_limit, upper_limit+1):
if i % 2 == 0:
print(i, end=" ")
The output of the python program to find even numbers in a given range is as follows:
PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter lower limit: 7
Enter upper limit: 21
8 10 12 14 16 18 20
Few important tips about this program
1. We take the lower and upper limit from the user and convert each one of them to integer data type.
2. Then within the range we find all the even numbers. Both the limites are inclusive in the range.
3. The logic is , a number is even if after divided by 2 the remainder is 0.
Python program to find even numbers in a given range snapshot:
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
Full Stack Web Developer & Data Science Enthusiast
Page Views :
Published Date :