Hi list,
Firstly, apologies for the low-level nature of this question - it's
really quite basic but I don't seem to be able to solve it.
I need to write a program that examines 3 variables x, y, z, and prints
the largest odd number. I've tried all sorts of variations and this is
the current version:
x, y, z = 26, 15, 20
if x > y and x > z and x%2 != 0:
print 'x is largest and odd'
elif y > x and y > z and y%2 != 0:
print 'y is largest and odd'
elif z > x and z > y and z%2 != 0:
print 'z is largest and odd'
else:
print 'no odd'
A solution should be possible using only the simple operators and
keywords above, no functions, lists or any other form of iteration.
(It's from p. 16 of Introduction to Computation and Programming Using
Python, and no, it's not "homework"!)
Many thanks,
Peter
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor