# # file: four_numbers.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. # # prints the introduction message def hello(): 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") def main(): hello() try: a = float(input("Please input a decimal number:")) b = float(input("Please input another decimal number:")) c = float(input("Please input the last decimal number:")) product(a,b,c) sum_(a,b,c) absolute_v(a,b,c) average(a,b,c) except: print("Incorrect input.") # finds the product of three values def product(x1,x2,x3): print("\nThe product of three numbers {0} x {1} x {2} = {3}".format(x1,x2,x3,x1*x2*x3)) # finds the sum of three values def sum_(s1,s2,s3): print("The sum of three numbers {0} + {1} + {2} = {3}".format(s1,s2,s3,s1+s2+s3)) def absolute_v(a,b,c): print("|{0:f}| = {1:f}".format(a,abs(a))) print("|{0:f}| = {1:f}".format(b,abs(b))) print("|{0:f}| = {1:f}".format(c,abs(c))) def average(a,b,c): print("({0} + {1} + {2})/3={3}".format(a,b,c,(a+b+c)/3.0)) main()