# Allison Obourn
# CSC 110, Spring 2018
# Lecture 21

# This program  reads data from a file in the format
# <id> <name> <hours worked day 1> <hours worked day 2> ...
# where each line represents one TA
# and outputs for each line the name, id, total number of
# hours worked and average hours per day

def main():
    file = open("tas.txt")
    lines = file.readlines()
    for i in range(len(lines)):
        ta = lines[i].split()
        print(ta[1], "(ID#" + ta[0] + ") worked ", end="")
        hours = get_total_hours(ta)
        hours_per_day = hours / (len(ta) - 2)
        print(round(hours, 1), "hours (" + str(round(hours_per_day, 1)) + " hours / day)")

# takes a list of ta data as a parameter.
# assumes that the first two tokens aren't numbers of hours
# and that the rest are. 
def get_total_hours(ta):
    hours = 0
    for j in range(2, len(ta)):
        hours += float(ta[j])
    return hours

main()
