# # file: four_f.py # # The program takes three values from the user (decimal values) and # returns their product, their sum, their absolute values, and their average. # Uses functions. # def main(): print "This program asks for three decimal numbers, and then finds:" print " their product,\n their sum,\n their absolute values,\n and their average" try: a,b,c=input("Please, input three numbers using comas (a,b,c):") product(a,b,c) sum_(a,b,c) absolute_v(a,b,c) average(a,b,c) except NameError: print "Your inputs are not all numbers. " except TypeError: print "You didn't input three numbers." except SyntaxError: print "You dind't input the numbers correctly. Example of a proper input: 2,3,1" except: print "Something went wrong." def product(x1,x2,x3): print print "The product of three numbers %0.2f x %0.2f x %0.2f = %0.2f" %(x1,x2,x3,x1*x2*x3) def sum_(s1,s2,s3): print print "The sum of three numbers %0.2f + %0.2f + %0.2f = %0.2f" % (s1,s2,s3,s1+s2+s3) def absolute_v(a,b,c): print print "|%f|=%f" %(a,abs(a)) print "|%f|=%f" %(b,abs(b)) print "|%f|=%f" %(c,abs(c)) def average(a,b,c): print print "(%0.2f + %0.2f + %0.2f)/3=%0.2f" % (a,b,c,(a+b+c)/3.0) main()