Выберите наибольшее нечетное число python



Я пытаюсь сделать простую программу на Python, которая вычисляет наибольшее нечетное число из значений x, y, z. как я могу дать пользователю возможность выбрать значения для x, y и z?



Таким образом, программа спросит, Что такое x,y и z,а затем скажет: "x, y, z-самый большой нечет" или все числа четные.

То, что я имею до сих пор, находится ниже. Это, по крайней мере, приличное начало?



  # This program exmamines variables x, y, and z 
# and prints the largest odd number among them

if x%2 !== 0 and x > y and y > z:
print 'x is the largest odd among x, y, and z'
elif y%2 !== 0 and y > z and z > x:
print 'y is the largest odd among x, y, and z'
elif z%2 !== 0 and z > y and y > x:
print 'z is the largest odd among x, y, and z'
elif x%2 == 0 or y%2 == 0 or z%2 == 0:
print 'even'


С помощью thkang post у меня теперь есть:



  # This program exmamines variables x, y, and z 
# and prints the largest odd number among them

if x%2 !== 0:
if y%2 !== 0:
if z%2 !== 0:
if x > y and x > z: #x is the biggest odd
elif y > z and y > x: #y is the biggest odd
elif z > x and z > y: #z is the biggest odd

else: #z is even
if x > y: #x is the biggest odd
else: #y is the biggest odd

else: #y is even
if z%2 != 0: #z is odd
if x > z: #x is the biggest odd
else: #z is the biggest odd
else: #y,z are even and x is the biggest odd

else: #x is even
if y%2 != 0 and z%2 != 0; #y,z is odd
if y > z: #y is the biggest odd
else: #z is the biggest odd
else: #x and y is even
if z%2 != 0: #z is the biggest odd
362   0  

Comments

    Ничего не найдено.