Jayteepix

Untitled

Oct 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #Adding or Subtracting two numbers
  2. print("Would you like to Add or Subtract two numbers?")
  3. operator = input("Enter 'A' for Add, 'S' for Subtract or if you prefer 'P' for Plus or 'M' for Minus > ")
  4. if operator == "A" or operator == "S" or operator == "P" or operator == "M" :
  5. input1 = input("Please enter your first number ")
  6. input2 = input("now enter your second number ")
  7. num1 = float(input1)
  8. num2 = float(input2)
  9. if operator == "A" or operator == "P":
  10. print("Add two numbers")
  11. result = num1 + num2
  12. output = str(result)
  13. print("The sum of " + input1 + " and " + input2 + " is " + output)
  14.  
  15. elif operator == "S" or operator == "M":
  16. print("Subtract two numbers")
  17. result = num1 - num2
  18. output = str(result)
  19. print("The subtraction of " + input1 + " and " + input2 + " is " + output)
  20. else:
  21. print("Try again and select 'A' / 'P' or 'S' / 'M' ")
  22. print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment