# --------------------------------------- # Joy and Beauty of Data # Assignment 2: Bowling # Bozeman High School # Partner 1 Name, Partner 2 Name # --------------------------------------- # --------------------------------------- # main: The function to call to start the solution. # --------------------------------------- def main(): bowling_file = open("bowling.txt", "r") number_of_games = int(bowling_file.readline()) for game_number in range(number_of_games): print("Game", game_number + 1) print("------------------------") game = read_game(bowling_file) score_game(game) print() bowling_file.close() # ---------------------------------------- # read_game: Reads a single game of bowling scores # ---------------------------------------- # file_name: The file that contains the bowling informatino # ---------------------------------------- # The function returns a list of numbers that shows # the result of each individual ball rolled. # ---------------------------------------- def read_game(file_name): rolls = [] for frame in range(10): # 10 frames per game data = file_name.readline().split() # read rolls for one frame for item in range(len(data)): # there will be 1, 2 or 3 rolls ball= int(data[item]) # convert to an integer rolls = rolls + [ball] # add to list of rolls return rolls # ---------------------------------------- main()