So I'm starting to learn Python (3.43) code on my own time and my friend who is a major in Comp Sci made up a little assignment for me to try to complete although I have no class experience. So what I need to do is make some code where the user is prompted to input how many scores to be entered and for hose to be inputed on each line which i have successfully completed. The hard part is figuring out how to make the min, max, and avg work into this. This is my cide thus far:

def scores():
        print('we are starting')
        count = int(input('Enter amount of scores: '))
        print('Each will be entered one per line')
        scoreList = []
        for i in range(1, count+1):
                scoreList.append(int(input('Enter score: ')))
        print('thank you the results are:')
        mysum = sum(count)
        # mysum needs to be a float
        average = 1.0*mysum / count
        print ('Total: ', str(count))
        print ('Average: ', str(average))
        print ('Minimum: ', str(min(count)))
        print ('Maximum: ', str(max(count)))

While a direct answer is helpful, I'd really like to understand what it is I may be doing wrong or some pointers on how to make it better. I understand my code skills are elementary but I'm trying to grasp the basics without paying a large amount for a class. I do however plan on taking a course once I can grasp the basics. thank you!

Edited by jennga: just a bit more info

2 Years
Discussion Span
Last Post by Gribouillis

Have two extra variables. Call them min and max.
Give min initially an impossible "high" value, say 999.
Give max initially an impossibl "low" value, say -1.
Now after every input of a score, compare that score to min and max.
Use lower than for min and higher than for max.
After input of all scores min should contain the lowest score and max the highest.


You must call the min() and max() functions with the argument scoreList instead of count. The same holds for sum()

print ('Minimum: ', str(min(scoreList)))
print ('Maximum: ', str(max(scoreList)))

You can also improve the input part:

scoreList.append(int(input('Enter score {:d}/{:d}: '.format(i, count))))

Edited by Gribouillis

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.