Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. 2. Suppose we have a text file, records.txt, of people's names and their weights. Each line of the file contains one name and one
1.
2.
Suppose we have a text file, records.txt, of people's names and their weights. Each line of the file contains one name and one weight, separated by a single space. Here is a sample file: Jack 86 Jill 100 Peter 96 Jenny 155 Write the definition of the function avg_weight, which returns the average weight of the people included in the file. The function takes in a one character config parameter, calculating the average weights of people whose names begin with the letter specified in the config parameter. If given the letter J, with the function call avg weight ( 'J'), the function would only compute the average weight people whose names began with the letter J - Jack, Jill, and Jenny, ignoring Peter's weight, in the sample file shown above. If given the star character * however, with the function all avg_weight(), the function includes the weight of every person in the file in the calculation. def avg_weight (config: str)floatStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started