######### # Assignment #K ########### # functions def scat(value_to_square): return value_to_square **2 def circum(radius): return 3.1417 * 2 * radius def circarea(radius): return 3.1417*scat(radius) def recarea(height,width): return height * width #### main ##### # Get user input for later calculations a = input("Please enter a number ") b = input("And another number ") # Note that NO error checking is done to make sure a and b are numbers. # In a real program, this should be done # Give the user a menu of actions to choose from quit = 1 # Allow user to make multiple choices with a loop while quit == 1: print "Please choose the number corresponding to your choice : " print " 1 - Calculate area of circle with radius of b" print " 2 - Calculate circumference of circle with radius b" print " 3 - Calculate area of rectangle with sides a and b " print " 4 - Calculate area of square with sides of a" print " 5 - End " choice = input("Enter your choice: ") # Handle the user's choice and handle invalid input if choice == 1: print "The area of a circle with radius ",b," is ", circarea(b) elif choice == 2: print "The circumference of a circle with radius ",b, " is ", circum(b) elif choice == 3: print "The area of a rectangle with sides of ", a, " and ",b, " is ", recarea(a,b) elif choice == 4: print "The area of a square with sides of ",a," is ", scat(a) elif choice == 5: quit = 0 else: print "That was not a valid choice" print # Print a final message for the user print "Thank you"