Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def do_calculation():
  2. print("lets do some " + command + " calculation.")
  3. #ask user how many numbers wants
  4. how_many = input("How many numbers> ")
  5. how_many = int(how_many)
  6. total = 0
  7. for number_count in range(how_many):
  8. number = input("Enter number " + str(number_count) + "> ")
  9. #total = adding total to integer number which user has input
  10. total = total + int(number)
  11. #result is total divide to variable(how_many) which stores amount of numbers input by user
  12. result = total / how_many
  13. if command == "average":
  14. print("the average = " + str(result))
  15. elif command == "total":
  16. #prints total
  17. print("total = " + str(total))
  18. finished = False
  19. while finished == False:
  20. print("Hi, I am Marvin, your personal bot.")
  21. command = input("How can I help? ")
  22. if command == "average":
  23. do_calculation()
  24. elif command == "total":
  25. do_calculation()
  26. elif command == "bye":
  27. finished = True
  28. else:
  29. print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement