Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi, I am Marvin, your personal bot")
- print("Today, I will calculate a mean average of some numbers for you.")
- # declare datatypes
- average_numbers = []
- total_numbers = 0
- # how many numbers you wish to average
- how_many = input("How many numbers do you want to average please? ")
- how_many = int(how_many)
- # Capture numbers you wish to average by using a For Loop
- for item_number in range(how_many):
- item = input("Please enter the number "+ str(item_number+1)+" out of "+ str(how_many) + " numbers? ")
- item = float(item)
- average_numbers.append(item)
- # Keep a running total of the numbers
- total_numbers = total_numbers + item
- # display the message
- print("You have entered the following " + str(how_many) + " numbers")
- # print all numbers
- for item in average_numbers:
- print(item)
- # Calculate mean average of numbers
- table_average = float(total_numbers/how_many)
- print("The average of your numbers is " + str(table_average))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement