作业帮 > 综合 > 作业

Write a program which asks the user for four numbers(Python)

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 05:35:17
Write a program which asks the user for four numbers(Python)
1) Write a program which asks the user for four numbers and then tells them one of the following:
· That there were more even numbers than odd numbers
· That there were more odd numbers than even numbers
· That there were the same number of even and odd numbers
evennum=0
oddnum=0
for i in range(0,4):
    num=input("please input a number:")
    if num%2==0:
        oddnum+=1
    else:
        evennum+=1
if evennum>oddnum:
    print "That there were more even numbers than odd numbers"
elif evennum<oddnum:
    print "That there were more odd numbers than even numbers"
else:
    print " That there were the same number of even and odd numbers"