In thid tutorial, we will discuss a concept of Python program to display even and odd number in the given range
when you devide a number by two and if the balance is zero, it is an even number
the odd number divided by two and if the balance is one, it is an odd number
Example of even number 2,4,6,8,…..
Example of odd number 1,3,5,7,…..
Here we will use a modular operator to display odd or even number in the given range.
if n%2==0, n is a even number
if n%2==1, n is a odd number
This program allows the user to enter two different digits and then, the program will display odd numbers and even numbers between entered digits using for loop
Program 1
Lower_Num=int(input("Enter the first number for range: ")) Upper_Num=int(input("Enter the second number for range: ")) print("Display the even numbers between two numbers are: ") for i in range(Lower_Num,Upper_Num+1): if(i%2==0): print(i) print("Display the odd numbers between two numbers are: ") for i in range(Lower_Num,Upper_Num+1): if(i%2==1): print(i)
When the above code is executed, it produces the following results
Enter the first number for range: 23 Enter the second number for range: 34 Display the even numbers between two numbers are: 24 26 28 30 32 34 Display the odd numbers between two numbers are: 23 25 27 29 31 33
Suggested for you
Similar post
C program to find a number is even or odd using the function
C program to separate Odd and Even numbers from an array
C program to Electricity bill calculation using the function
C program to display all even and odd numbers from 1 to n
C program display odd and even numbers without if statements
C program to calculate the sum of odd and even numbers
C program to find whether a number is even or odd
C++ program to find a number is even or odd using the function
C++ program to separate Odd and Even numbers from an array
C++ program to display all even and odd numbers from 1 to n
C++ program calculate Average of odd and even numbers in an array
C++ program to calculate the sum of odd and even numbers
C++ program to find whether a number is even or odd
Java program to find a number is even or odd using the method
Java program to separate Odd and Even numbers from an array
Java program to display all even and odd numbers from 1 to n
Java program display odd and even numbers without if statements
Java program to calculate the sum of odd and even numbers
Java program to find whether a number is even or odd
Python program check whether a number is odd or even
Python program to check a number is even or odd using the function
Python code to print even and odd numbers without if
Python code to print even and odd number in the given range
Separate odd and even numbers in a list to different two list
Python Program to find odd and even numbers from a list
Java program to calculate sum of odd and even numbers
C++ program to calculate sum of odd and even numbers
Python program to calculate sum of odd and even numbers
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…