Tom_Jung

Untitled

Jan 16th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. print("Hi, I am R4D4, your personal math bot")
  2. command = input("How may I help you: add, subtract or average? ")
  3.  
  4. if command == "add" or command == "plus":
  5. print("Let's add some numbers")
  6. number1 = int(input("number 1: "))
  7. number2 = int(input("number 2: "))
  8. result = number1 + number2
  9.  
  10. print("Results:", number1, "+" ,number2, "=", result)
  11.  
  12. elif command == "subtract" or command == "minus":
  13. print("Let's substract some numbers")
  14. number1 = int(input("number 1: "))
  15. number2 = int(input("number 2: "))
  16. result = number1 - number2
  17.  
  18. print("Results:", number1, "minus", number2, "=", result)
  19.  
  20. elif command == "average":
  21. how_many = input("How many numbers do you wan to average? ")
  22. how_many = int(how_many)
  23. total = 0
  24. for number_count in range(how_many):
  25. number = input("Enter number " + str(number_count) + " = ")
  26. total = total + int(number)
  27. result = total / how_many
  28. print("average is = " + str(result))
  29.  
  30. else:
  31. print("Sorry, this is the add or subtract or average math bot")
Advertisement
Add Comment
Please, Sign In to add comment