我想知道我下面的答案是正确的和可行的还是有什么改进谢谢。
问题:一个程序检查x y和z是否奇数或偶数是否为奇数的程序检查这三个数中的最大值。
下面是我的答案:x = 4
y = 7
z = 9
#first condition where 3 numbers are all odd.
if x%2 == 1 and y%2 == 1 and z%2 == 1:
if x > y and x > z:
print "x is the biggest odd number."
elif x > y and z > x:
print "z is the biggest odd number."
else:
print "y is the biggest odd number."
#second condition where 2 of the numbers are odd
elif x%2 == 0 and y%2 == 1 and z%2 == 1:
if y > z:
print "y is the biggest odd number."
else:
print "y is the biggest odd number."
elif x%2 == 1 and y%2 == 0 and z%2 == 1:
if x > z:
print "x is the biggest odd number."
else:
print "z is the biggest odd number."
elif x%2 == 1 and y%2 == 1 and z%2 == 0:
if x > y:
print "x is the biggest odd number."
else:
print "y is the biggest odd number."
#third condition where only one of the numbers is odd.
elif x%2 == 0 and y%2 == 0 and z%2 == 1:
print "z is the biggest odd number."
elif x%2 == 1 and y%2 == 0 and z%2 == 0:
print "x is the biggest odd number."
elif x%2 == 0 and y%2 == 1 and z%2 == 0:
print "y is the biggest odd number."
#last condition if none of the numer are odd or not numbers.
else:
print " None of the numbers are odd or not a number."