# Kids3 Example # Source code file: kids3.py # Input file: kids.txt # Compute the maximum age of the girls. maximum = 0 fin = open("kids.txt", "r") # Read and process first line from file line = fin.readline( ) fields = line.split(",") name = fields[0].strip( ) gender = fields[1].strip( ) age = int(fields[2].strip( )) if gender == "M": maximum = max(maximum, age) # Process lines until end of file while line != "": fields = line.split(",") name = fields[0].strip( ) gender = fields[1].strip( ) age = int(fields[2].strip( )) if gender == "M": maximum = max(maximum, age) line = fin.readline( ) print("Maximum age of boys:", maximum) fin.close( ) # Output: # Maximum age of boys: 10