# this program will calculate total hours worked by a TA, the average hours worked # per day and report how many of the days a TA put in more hours than average for line in open("hours.txt"): id, output, *days = line.split() # sum hours, making sure to cast from string to float total_hours = 0 for hours in days: total_hours += float(hours) average = total_hours/len(days) above_ave = 0 for hours in days: if float(hours) > average: above_ave += 1 output += " worked %.1f hours, %.1f hours / day, " % (total_hours, average) print(output + str(above_ave) + " days above average")