> Python help with calling files to average them?

Python help with calling files to average them?

Posted at: 2014-12-18 
Do you have five numbers, that are the results of

test scores, and are you asking us how to find the

average score?

If you are asking this, then you are not thinking.

Otherwise, I apologize, but your question seems

to ask just this.

>

> John (gnujohn)

Still cant figure out how to assign the percents to something out of the file so I can add them and average

Here is my problem: A program named readscores.py that reads tests.txt, displays all of the scores, and the average of the scores. This program must also use a loop.



Earlier I made a program that stored test scores given by inputs using a loop(Had to use one) as this:

myfile = open('test.text', 'w')

for number in range(1,6):

score = input('Enter the percent score of your five tests:')

myfile.write(str(score) + '\n')

myfile.close()

print('We have logged your grades')

I had to use a loop and log them as percents. Now I need to call them on the problem above.

This is what I have so far:

myfile = open('test.text', 'r')

print('Here are your test scores:')

for line in myfile:

print(line)



myfile.close()

Problem I am having is how do I get the average of the 5 tests so I can display it.