Learning Python: Loop through a file.

Looping through file and counting and average them out.

x = 0
count = 0
file = open("test.txt")

for line in file:
x += float(line)
count = count + 1
print x, count, x/count


test.txt

0.8475
0.6178
0.6961
0.7565
0.7626
0.7556
0.7002
0.7615
0.7601
0.7605
0.6959
0.7606
0.7559
0.7605
0.6932
0.7558
0.6526
0.6948
0.6528
0.7002
0.7554
0.6956
0.6959
0.7556
0.9846
0.8509
0.9907