Advertisement
Pedroleon

Untitled

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