Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Adding or Subtracting two numbers
- print("Would you like to Add or Subtract two numbers?")
- operator = input("Enter 'A' for Add, 'S' for Subtract or if you prefer 'P' for Plus or 'M' for Minus > ")
- if operator == "A" or operator == "S" or operator == "P" or operator == "M" :
- input1 = input("Please enter your first number ")
- input2 = input("now enter your second number ")
- num1 = float(input1)
- num2 = float(input2)
- if operator == "A" or operator == "P":
- print("Add two numbers")
- result = num1 + num2
- output = str(result)
- print("The sum of " + input1 + " and " + input2 + " is " + output)
- elif operator == "S" or operator == "M":
- print("Subtract two numbers")
- result = num1 - num2
- output = str(result)
- print("The subtraction of " + input1 + " and " + input2 + " is " + output)
- else:
- print("Try again and select 'A' / 'P' or 'S' / 'M' ")
- print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment