Advertisement
lubattillah

do calculation

May 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  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")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement