GRAND ASSIGNMENT - 2 Evens and Odds

 Evens and Odds

Write a program to count even and odd numbers in given range [M, N]. Both M, N are inclusive in [M, N].
Input

The first line of the input will be an integer(M).
The Second line of the input will be an integer(N).
Output

The first line of output should be a number of odds count.
The second line of output should be a number of even counts.
Explanation

For example, if the given range is 2 to 11
odds numbers in the range are 3, 5, 7, 9, 11 then count is 5.
even numbers in the range are 2, 4, 6, 8, 10 then count is 5.
Sample Input 1
2
11
Sample Output 1
5
5
Sample Input 2
-5
7
Sample Output 2
7
6









m=int(input(""))
n=int(input(""))
j=0
k=0
for i in range(m,n+1):
    if i%2==0:
        j+=1 
    else:
        k+=1 
print(k)
print(j)
2
11
5
5

-5
7
7
6

Comments

Popular posts from this blog

CODING ASSIGNMENT 3 Library Management

CODING PRACTICE 11 Music Page

CCBP Static Website Coding Assignment 2 Solution | Yoga Page