77 956
Assignments Done
Successfully Done
In August 2019

Answer to Question #20933 in Python for Andre

Question #20933
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)

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
Expert's answer

odd = 0
even = 0

while True:
num = int(input("Enter a number: "))

if num == -1:
elif num%2==0:
even += 1
odd += 1

print ("Number of even number: "+str(even))
print ("Number of odd number: "+str(odd))

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions