SHARE
TWEET

do calculation

lubattillah May 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def do_calculation():
  2.     print("lets "+command+" some numbers")
  3.     input1 = input("Number 1> ")
  4.     input2 = input("Number 2> ")
  5.     number1 = int(input1)
  6.     number2 = int(input2)
  7.     if command=="add":
  8.         result = number1+number2
  9.         operator = "+"
  10.     elif command=="subtract":
  11.         result = number1-+number2
  12.         operator = "-"
  13.     output = str(result)
  14.     print(input1+operator+input2+"="+output)
  15. finished=False
  16. while finished==False:
  17.     print("Hi, I am Khamisi, your personal bot.")
  18.     command=input("How can I help? ")
  19.     if command=="add":
  20.         do_calculation()
  21.     elif command=="subtract":
  22.         do_calculation()
  23.     elif command=="bye":
  24.         finished=True
  25.     else:
  26.         print("Sorry I don't understand this")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top