Nov-24-2018, 02:57 AM
(This post was last modified: Nov-24-2018, 04:00 AM by ichabod801.)
#!/usr/bin/env python3 # Simple Calculator # Function to subtract def subtract(x, y): return int(x) - int(y) # Function to multiply def multiply(x, y): return int(x) * int(y) # Function to add def add(x, y): return int(x) + int(y) # Function to divide def divide(x, y): return int(x) / int(y) # Show a menu print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") # ASk for user input choice = input("Enter choice(1/2/3/4):") # ASk for two numbers and Turn input strings to integers num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) # Check the choice and send the values to the correct function if choice == 1: print(num1,"+",num2,"=", add(num1,num2)) elif choice == 2: print(num1,"-",num2,"=", subtract(num1,num2)) elif choice == 3: print(num1,"*",num2,"=", multiply(num1,num2)) elif choice == 4: print(num1,"/",num2,"=", divide(num1,num2)) else: print("Invalid input")i also need to know tha the answer would be to this question?
After fixing the function, test it using the numbers 10 and 46. What is the last line of the output?