Python Forum
numbers in list - max value and average - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: numbers in list - max value and average (/thread-25517.html)



numbers in list - max value and average - stewie - Apr-01-2020

Program ask user for input (how many fish he caught per day - 10 days) and than it needs to output average per day and output number from list that is higher than average

list = []
above_average = 0
i = 1
while i < 11:
    fish = int(input("Catched fish today: "))
    list.append(fish)
    i+=1
    average = sum(list) / len(list)
    if fish > average:
        above_average += 1
print ("Average per day: " + str(average))
print ("Catch above average " + str(above_average))
This is what i've done and it works but at catch above average i need to print which number from list is higher than average not how many...


Fisherman Alex - stewie - Apr-01-2020

Fisherman Alex needs to enter amount of fish he catched every day for 10 days.

Program needs to return average for every day and number of day he catched more fish than average

list = []
above_average = 0
i = 1
while i < 11:
    fish = int(input("Catched fish today: "))
    list.append(fish)
    i+=1
    average = sum(list) / len(list)
    if fish > average:
        above_average += 1
print ("Average per day: " + str(average))
print ("Catch above average " + str(above_average))


This is what i've done and it works but at catch above average i need to print which number from list is higher than above not how many...


RE: numbers in list - max value and average - buran - Apr-01-2020

you need to store the user input in a list. Then, after all numbers are in the list - iterate over list and find [count of] numbers that are higher than average