Write a program that repeatedly asks a user to enter a number. Terminate the program when the user enters -1. The program should display the number of even and odd numbers entered by the user. (Exclude -1)
Sample:
Enter a number: 4
Enter a number: 7
Enter a number: 2
Enter a number: 8
Enter a number: -1
Number of even number: 3
Number of odd number: 1
1
Expert's answer
2012-12-24T10:59:19-0500
odd = 0 even = 0
while True: num = int(input("Enter a number: "))
if num == -1: break; elif num%2==0: even += 1 else: odd += 1
print ("Number of even number: "+str(even)) print ("Number of odd number: "+str(odd))
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment