Evens and Odds in Python

Problem Statement:

In this Evens and Odds in Python, we are given two numbers, we need to find the count of even and odd numbers that come in between these two numbers including these two numbers.

Code for Evens and Odds in Python:

n1 = int(input('Enter 1st number: '))
n2 = int(input('Enter 2nd number: '))
even = 0
odd = 0
for i in range(n1, n2+1):
    if i%2==0:
        even += 1
    else:
        odd += 1
        
print('Even: ', even)
print('Odd: ', odd)

Output:

Evens and Odds in Python

Also Read:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you