Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Python program to make basic calculator
- def multiplication(num1, num2):
- return num1 * num2
- def addition(num1, num2):
- return num1 + num2
- def subtraction(num1, num2):
- return num1 - num2
- def divide(num1, num2):
- return num1 / num2
- finished = False
- while finished == False:
- print("Hi, I am your personal calculator. I can help you with the following operations: ")
- print("Select a number: 1-Addition, 2-Subtraction, 3-Multiplication, 4-Division, 5-End")
- operation = int(input("Choose number of operation: 1/2/3/4/5 : "))
- if operation == 5:
- print()
- print("Have a good day, bye.")
- break
- if (operation >= 1) and (operation <=5):
- pass
- else:
- print()
- print("The number of the operation must be between 1 and 5.")
- break
- value1 = int(input("Enter 1st number: "))
- value2 = int(input("Enter 2nd number: "))
- if operation == 1:
- print(value1, "+", value2, "=", addition(value1, value2))
- print()
- elif operation == 2:
- print(value1, "-", value2, "=", subtraction(value1, value2))
- print()
- elif operation == 3:
- print(value1, "*", value2, "=", multiplication(value1, value2))
- print()
- elif operation == 4:
- print(value1, "/", value2, "=", divide(value1, value2))
- print()
Advertisement
Add Comment
Please, Sign In to add comment