Advertisement
HBSB

2.14 + and - with comments

Mar 1st, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1.  
  2. # I want this program to help with simple calculations
  3. print ("Hi, I am Marvin, your personal bot")
  4. command = input ("How can I help?")
  5. # I might need to give the user more of a clue to the response
  6. # needed from them but will expect them to know for now
  7. # the first option is addition
  8. if command == "add":
  9.   print ("lets add some numbers")
  10.   input1 = input("Number 1> ")
  11.   input2 = input("Number 2> ")
  12.   number1 = int(input1)
  13.   number2 = int(input2)
  14.   result = number1 + number2
  15.   output = str(result)
  16.   print(input1 + " + " + input2 + " = " + output)
  17. # the next option is subtraction
  18. elif command == "subtract":
  19.   print ("lets subtract some numbers")
  20.   input1 = input ("Number1>")
  21.   input2 = input ("Number2>")
  22.   number1 = int(input1)
  23.   number2 = int(input2)
  24.   result = number1 - number2
  25.   output = str(result)
  26.   print(input1 + " - " + input2 + " = " + output)
  27. # or if the user input doesn't match then tell them
  28. else:
  29.   print ("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement