Answer:
def student_minmax(filename):
"""
Description: Reads student names and finds min and max score
Input: Name of the file that has the student data
Output: Dictionary with name as key and value is a list with min and max values
"""
# Dictionary that holds the results
studentDict = {}
# Opening and reading file
with open(filename, "r") as fp:
# Reading data line by line
for line in fp:
# Stripping new line
line = line.strip()
# Splitting into fields
fields = line.split(' ')
# Getting name and scores
name = fields[0]
scores = []
scoresStr = fields[1:]
# Converting to integer
for score in scoresStr:
scores.append(int(score))
# Storing in dictionary
studentDict[name] = []
studentDict[name].append(min(scores))
studentDict[name].append(max(scores))
# Returning dictionary
return studentDict
# Testing function
resDict = student_minmax("d:\\Python\\studentMarks.txt")
# Printing dict
print(resDict)
Step-by-step explanation: