• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Dec 3rd, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #Simple Calculator from High School Computer Programming - python v3.0
2. #Function definitions for each operation
3. def multiply(x, y):
4.    print(x * y)
5.
6. def divide(x, y):
7.    print (x / y)
8.
10.    print (x + y)
11.
12. def subtract(x, y):
13.    print (x - y)
14. #print is used in Python to print out on the screen
15. print("Choose an operation")
16. print("1.Multiply")
17. print("2.Divide")
19. print("4.Subtract")
20. #creates a variable 'number' to get the input from a user
21. number = input("Enter choice between 1 and 4: ")
22. #Declares a variable 'x' and 'y' and saves the input as an integer, input is saved as a string by default!
23. x = int(input("Enter the first whole number "))
24. y = int(input("Enter the second whole number: "))
25. #Basically a goto check. If a number is equal to one of the operations, it does it. Otherwise, an error occurs.
26. if number == '1':
27.     multiply(x,y)
28. elif number == '2':
29.     divide(x,y)
30. elif number == '3':