Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #python calculator
- #steve basford 2015
- def add():
- answer = (num1) + (num2)
- print (answer)
- def subtract():
- answer = (num1) - (num2)
- print (answer)
- def divide():
- if num1 == "0"
- answer = (num1) / (num2)
- print (answer)
- def multiply():
- answer = (num1) * (num2)
- print (answer)
- print("Welcome to my very first calculator!")
- choice = input("(A)ddition (S)ubtraction (D)ivision (M)ultiplication")
- num1 = int(input("Enter the first number"))
- num2 = int(input("Enter the second number"))
- if choice == "a":
- add()
- elif choice == "s":
- subtract()
- elif choice == "d":
- divide()
- elif choice == "m":
- multiply()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement