0

HELP!!

Write a program that examines three variables - x, y, and z -and print the largest odd number among them. If none of them are off it should print message to that effect.

12th Sep 2019, 6:54 AM
LaDarien Rancher
LaDarien Rancher - avatar
3 Antworten
+ 1
Hello - please don't write sentences in the tags as it makes it difficult for other users to find posts when searching. Could you show us your attempt at writing this program?
12th Sep 2019, 7:14 AM
Rincewind
Rincewind - avatar
+ 1
Python: x = 6 y = 8 z = 9 odd_numbers = [] if x % 2 != 0: odd_numbers.append(x) if y % 2 != 0: odd_numbers.append(y) if y % 2 != 0: odd_numbers.append(z) if len(odd_numbers) != 0: print("Odd numbers:") for number in odd_numbers: print(number) else: print("No odd numbers.")
12th Sep 2019, 10:29 AM
Seb TheS
Seb TheS - avatar
0
Rincewind my apologies but here is my attempt. x=int(input('x=')) y=int(input('y=')) z=int(input('z=')) if x>y and x>z and x%2!=0: print (x,'is the largest odd number') elif y>z and y>x and y%2!=0: print (y,'is the largest off number') elif z>x and z>y and z%2!=0: print (z,'is the largest odd number') else: print ('the number', x,y,'and', z,'have no odd number')
12th Sep 2019, 12:19 PM
LaDarien Rancher
LaDarien Rancher - avatar