Advertisement
HBSB

2.14

Mar 1st, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 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. elif command == "addition" :
  18.   input1 = input("Number 1> ")
  19.   input2 = input("Number 2> ")
  20.   number1 = int(input1)
  21.   number2 = int(input2)
  22.   result = number1 + number2
  23.   output = str(result)
  24.   print(input1 + " + " + input2 + " = " + output)
  25.  
  26. # the next option is subtraction
  27. elif command == "subtract":
  28.   print ("lets subtract some numbers")
  29.   input1 = input ("Number1>")
  30.   input2 = input ("Number2>")
  31.   number1 = int(input1)
  32.   number2 = int(input2)
  33.   result = number1 - number2
  34.   output = str(result)
  35.   print(input1 + " - " + input2 + " = " + output)
  36. elif command == "take away":
  37.   print ("lets take away, or subtract, some numbers")
  38.   input1 = input ("Number1>")
  39.   input2 = input ("Number2>")
  40.   number1 = int(input1)
  41.   number2 = int(input2)
  42.   result = number1 - number2
  43.   output = str(result)
  44.   print(input1 + " - " + input2 + " = " + output)  
  45.  
  46. # or if the user input doesn't match then tell them
  47. else:
  48.   print ("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement