Assignment1.py
def topRead(bracket, read):
    '''
    For each participant in a given age bracket, calulates the participant who read the most number of books, checks if there is
    a tie, and if no participants read any books returns N/A. returns the topReader (winner), and the TOTAL number of books 
    the age bracket read. Primarily used in the option 3 funtion. Whenever a new "best" reader is assigned its first name and 
    last name are placed into the firstName() and lastName() functions to properly format them. 
    Below are index's for easier readability / debugging.

    bracket[lcn][0] = FIRSTNAME
    bracket[lcn][1] = LASTNAME

    Para:
            bracket: dictionary
            read: dictionary

    Returns:
            topReader: string
            bracketCount: integer 
    '''
    bracketCount = 0
    topReader = 'N/A'
    
    record = 0 
    for lcn in bracket:
        personalCount = 0 

        # if KEYERROR occurs the dictionary was empty ie, there was not a participant who read any books this summer.
        # we do not care about the specific book that was read, only the tally for the total books read
        try:
            for book in read[lcn]: 
                personalCount += 1
                bracketCount += 1 
            if personalCount > record:
                record = personalCount
                topReader = ' '.join([firstName(bracket[lcn][0]), lastName(bracket[lcn][1])])
            elif personalCount == record:
                topReader = 'Tied!'
        except KeyError:
            topReader, bracketCount = 'N/A', 0
    return topReader, bracketCount

    For each participant in a given age bracket, calulates the participant who read the most number of books, checks if there is
    a tie, and if no participants read any books returns N/A. returns the topReader (winner), and the TOTAL number of books 
    the age bracket read. Primarily used in the option 3 funtion. Whenever a new "best" reader is assigned its first name and 
    last name are placed into the firstName() and lastName() functions to properly format them. 
    Below are index's for easier readability / debugging.

    bracket[lcn][0] = FIRSTNAME
    bracket[lcn][1] = LASTNAME

    Para:
            bracket: dictionary
            read: dictionary

    Returns:
            topReader: string
            bracketCount: integer 
    
For each participant in a given age bracket, calulates the participant who read the most number of books, checks if there is
a tie, and if no participants read any books returns N/A. returns the topReader (winner), and the TOTAL number of books
the age bracket read. Primarily used in the option 3 funtion. Whenever a new "best" reader is assigned its first name and
last name are placed into the firstName() and lastName() functions to properly format them.
Below are index's for easier readability / debugging.

bracket[lcn][0] = FIRSTNAME
bracket[lcn][1] = LASTNAME

dictionary
read: dictionary
For each participant in a given age bracket calulates the participant who read the most number of books checks if there is a tie and if no participants read any books returns N / A . returns the topReader ( winner ) and the TOTAL number of books the age bracket read . Primarily used in the option 3 funtion . Whenever a new " best " reader is assigned its first name and last name are placed into the firstName () and lastName () functions to properly format them . Below are index ' s for easier readability / debugging . bracket [ lcn ] [ 0 ] = FIRSTNAME bracket [ lcn ] [ 1 ] = LASTNAME dictionary read : dictionary
def topRead(bracket, read):
    bracketCount = 0
    topReader = 'N/A'
    record = 0 
    for lcn in bracket:
        personalCount = 0 
        try:
            for book in read[lcn]: 
                personalCount += 1
                bracketCount += 1 
            if personalCount > record:
                record = personalCount
                topReader = ' '.join([firstName(bracket[lcn][0]), lastName(bracket[lcn][1])])
            elif personalCount == record:
                topReader = 'Tied!'
        except KeyError:
            topReader, bracketCount = 'N/A', 0
    return topReader, bracketCount
def topRead ( bracket , read ) : bracketCount = 0 topReader = 'N/A' record = 0 for lcn in bracket : personalCount = 0 try : for book in read [ lcn ] : personalCount += 1 bracketCount += 1 if personalCount > record : record = personalCount topReader = ' ' . join ( [ firstName ( bracket [ lcn ] [ 0 ] ) , lastName ( bracket [ lcn ] [ 1 ] ) ] ) elif personalCount == record : topReader = 'Tied!' except KeyError : topReader , bracketCount = 'N/A' , 0 return topReader , bracketCount
For each participant in a given age bracket, calulates the participant who read the most number of books, checks if there is
a tie, and if no participants read any books returns N/A.
For each participant in a given age bracket calulates the participant who read the most number of books checks if there is a tie and if no participants read any books returns N / A .
'''
    For each participant in a given age bracket, calulates the participant who read the most number of books, checks if there is
    a tie, and if no participants read any books returns N/A. returns the topReader (winner), and the TOTAL number of books 
    the age bracket read. Primarily used in the option 3 funtion. Whenever a new "best" reader is assigned its first name and 
    last name are placed into the firstName() and lastName() functions to properly format them. 
    Below are index's for easier readability / debugging.

    bracket[lcn][0] = FIRSTNAME
    bracket[lcn][1] = LASTNAME

    Para:
            bracket: dictionary
            read: dictionary

    Returns:
            topReader: string
            bracketCount: integer 
    ''' # if KEYERROR occurs the dictionary was empty ie, there was not a participant who read any books this summer.
 # we do not care about the specific book that was read, only the tally for the total books read

string
bracketCount: integer
string bracketCount : integer
topReader
bracket
read