Advertisement
braconnier

Def_4.10-exer.py

Dec 6th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. def total_average():
  2. total=0
  3. if command=="total":
  4. for number_count in range (how_many):
  5. number = input("Enter number " +str(number_count+1) + " > ")
  6. total = total + int(number)
  7. print ("Total =" + str(total))
  8. elif command == "average":
  9. for number_count in range (how_many):
  10. number = input("Enter number " +str(number_count+1) + " > ")
  11. total = total + int(number)
  12. result = total / how_many
  13. print ("the average = " + str(result))
  14.  
  15. else:
  16. print ("Sorry I don't understand")
  17.  
  18.  
  19. finished= False
  20. while finished == False:
  21. print("Hi, I am Marvin, your personal bot")
  22. how_many = input("How many numbers > ")
  23. how_many = int(how_many)
  24. command = input ("what do you want to do : total or average > ? ")
  25.  
  26. if command =="total":
  27. total_average()
  28. elif command=="average":
  29. total_average()
  30. elif command =="bye":
  31. finished = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement