# Program to find minimum of 3 numbers
# (user enters numbers)
# Matt Bishop, May 1, 2009
# for ECS 10 Spring 2009
# this routine finds the minimum of 3 numbers by comparison among all
# parameters: a, b, c: the three numbers
# returns: smallest of a, b, c
def least(a, b, c):
if a < b and a <= c:
minim = a;
elif b < a and b < c:
minim = b;
else:
minim = c;
return minim;
# get 3 numbers and print minimum; also handle bogus input
# calls: least
def main():
try:
# get input and print result
a,b,c = input("enter three comma-separated numbers: ");
print "The minimum of", a, "and", b, "and", c, "is", least(a, b, c);
# now handle errors
except (NameError, ValueError):
print "Bad form for input -- did you enter three numbers?"
except SyntaxError:
print "Bad form for input -- did you forget commas?"
main();