Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #get users input
- op = input("Operation: ")
- num1 = float(input("First Number:"))
- num2 = float(input("Second Number:"))
- #define the 5 operation functions
- def addition(a, b):
- print(float(num1 + num2))
- def subtract(a, b):
- print(float(num1 - num2))
- def multiply(a, b):
- print(float(num1 * num2))
- def divide(a, b):
- print(float(num1 / num2))
- def exponent(a, b):
- print(float(num1 ** num2))
- #according to what user input, the operations are printed out accordingly
- if op == '+':
- addition(num1, num2)
- if op == '-':
- subtract(num1, num2)
- if op == '*':
- multiply(num1, num2)
- if op == '/':
- divide(num1, num2)
- if op == '^':
- exponent(num1, num2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement