Advertisement
Pedroleon

bot2 program + while

Jan 13th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. # bot program + while
  2. finished = False
  3. while finished ==False:
  4. print("Hi, I am Marvin, your personal bot.")
  5. phrase = input("Whats your name ? >")
  6. print(" Morning " + phrase + " Do you want to add or substract ?")
  7. command = input("How can I help ?")
  8. if command == "add" or command == "plus":
  9. print("Let's add 3 numbers.")
  10. input1 = input("Number 1> ") # input numbers are strings#
  11. input2 = input("Number 2> ")
  12. input3 = input("Number 3> ")
  13. number1 = int(input1) # use int to convert string to integer#
  14. number2 = int(input2)
  15. number3 = int(input3)
  16. result = number1 + number2 + number3 # by using add #
  17. output = str(result) # result of operation#
  18. print(input1 + " + " + input2 + " + " + input3 + " = " + output)
  19. elif command == "substract":
  20. print(" Let's substract some numbers.")
  21. input1 = input("Number 1> ")
  22. input2 = input("Number 2> ")
  23. number1 = int(input1)
  24. number2 = int(input2)
  25. result = number1 - number2
  26. output = str(result)
  27. print(input1 + " - " + input2+" = " + output)
  28. elif command == "bye":
  29. finished = True
  30. else:
  31. print("Sorry, I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement