Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Calculator Bot
- #I can Add, Subtract, Multiply and Divide two numbers
- print("Would you like to Add or Subtract, Multiply or Divide two numbers?")
- operator = input("Enter 'A' for Add, 'S' for Subtract, 'M' for Multiply or 'D' for Divide > ")
- if operator == "A" or operator == "S" or operator == "M" or operator == "D" :
- input1 = input("Please enter your first number ")
- input2 = input("now enter your second number ")
- num1 = float(input1)
- num2 = float(input2)
- if operator == "A":
- print("Add two numbers")
- result = num1 + num2
- output = str(result)
- print("The sum of " + input1 + " and " + input2 + " is " + output)
- elif operator == "S":
- print("Subtract two numbers")
- result = num1 - num2
- output = str(result)
- print("The subtraction of " + input1 + " and " + input2 + " is " + output)
- elif operator == "M":
- print("Multiply two numbers")
- result = num1 * num2
- output = str(result)
- print("The multiplication of " + input1 + " by " + input2 + " is " + output)
- elif operator == "D":
- print("Divide two numbers")
- if num2 == 0:
- print("Can't divide by Zero sorry")
- else:
- result = num1 / num2
- output = str(result)
- print("The division of " + input1 + " by " + input2 + " is " + output)
- else:
- print("Try again and select 'A' / 'S' or 'M' / 'D' ")
- print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment