Answer:
see explaination
Step-by-step explanation:
# python code filereader.py
import sys
import readline
from sys import stdin
import random
## Open the file with read only permit
f = open('inputfile.txt')
## Read the first line
sum = 0.0
count = 0
#read file till the file is empty
while True:
line = f.readline()
if ("" == line):
print "Average age of friends is", sum/count
break
list = line.split()
print "My friend ",list[0], " is", list[1]
sum = sum + int(list[1])
count = count + 1
f.close()
'''
inputfile.txt
Denny 24
Penny 28
Lenny 20
Jenny 24
output:
My friend Denny is 24
My friend Penny is 28
My friend Lenny is 20
My friend Jenny is 24
Average age of friends is 24.0
see screenshot at attachment