Advertisement
M_Asif_Khan

mean_average

Feb 26th, 2020
216
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("Today, I will calculate a mean average of some numbers for you.")
  3.  
  4. # declare datatypes
  5. average_numbers = []
  6. total_numbers = 0
  7.  
  8. # how many numbers you wish to average
  9. how_many = input("How many numbers do you want to average please? ")
  10. how_many = int(how_many)
  11.  
  12. # Capture numbers you wish to average by using a For Loop
  13. for item_number in range(how_many):
  14. item = input("Please enter the number "+ str(item_number+1)+" out of "+ str(how_many) + " numbers? ")
  15. item = float(item)
  16. average_numbers.append(item)
  17. # Keep a running total of the numbers
  18. total_numbers = total_numbers + item
  19.  
  20. # display the message
  21. print("You have entered the following " + str(how_many) + " numbers")
  22.  
  23. # print all numbers
  24. for item in average_numbers:
  25. print(item)
  26.  
  27. # Calculate mean average of numbers
  28. table_average = float(total_numbers/how_many)
  29.  
  30. print("The average of your numbers is " + str(table_average))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement