Answer to Question #176590 in Python for adhi chinna

Question #176590

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.


1
Expert's answer
2021-03-29T06:25:47-0400
M = int(input("Enter M: "))
N = int(input("Enter N: "))
if M >= N:
    print("Wrong range!")
else:
    print("Odds: ", end = "")
    for i in range(M, N+1):
        if i % 2 == 1:
            print(i, end = " ")
    print("")
    print ("Even: ", end = "")
    for i in range(M, N+1):
        if i % 2 == 0:
            print(i, end = " ")
    print("")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS