Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are the architect of an all-new boxing tournament and you intend to experiment with a new weight categorization system that encourages healthy training
You are the architect of an all-new boxing tournament and you intend to experiment with a new weight categorization system that encourages healthy training practices. To beat the old pen-and-paper tournaments, you would have to use your superior programming skills to write a function that uses the data of the athletes to categorize them. Write a function WeightClass that takes a list of dictionaries weightList as a parameter and returns a dictionary of weight categories for each boxer. The input follows the following format: 1. Input is a list of dictionaries 2. Each dictionary contains 3 keys: Name, 0 and 1 3. 0 corresponds to a list of weights measured during the off-season and 1 corresponds to a list of weights measured during the tournament season An example of the input is given below: weightList [ { "Name": "Sugar Ray", 0: [158,167,173, 170], 1: [159, 157, 145,149]}, {"Name": "Ali", 0: [220, 231,218,204], 1: [198,194, 209, 216]},. .] The function WeightClass evaluates the category using the following criteria: The average weights for off-season and in-season are computed by averaging over their respective lists . Weighted average is measured using the above averages with a weight of 0.7 and 0.3 assigned to in-season and off-season averages respectively. weighted Average = 0.7xinSeason Average + 0.3xoff Season Average = The weighted average is then used to categorize the boxer into their weight class as follows weighted average 200: Heavyweight ("H") 150 weighted average < 200 : Middleweight ("M) weighted average < 150: Lightweight ("L") Returns a dictionaries with the names of the boxers as keys and their weight class indicated with the letter as the values def WeightClass (weightList): Parameters: weightList (list) Return value: dictionary with names and weight classes indicated with the letters Important notes: Comments: your program should have a header and comments that explain the solution steps. main function: write the appropriate code to test the functions you implemented. This part will not be graded. (Do not use input statements) Remember to add the main call at the end of the program as follows: "1 main ": if name main () Save your file as lab12.py and upload it to Vocareum Examples Input/Output: Sample Input: [ { "Name": "Sugar Ray", 0: [158,167,173, 170], 1: [159,157,145, 149]}, {"Name": "Ali", 0: [220, 231,218,204], 1: [198, 194,209,216]}, {"Name":"Pacquiao", 0: [153, 151, 148,140], 1: [147, 145, 144, 145]}] Sample Output: {'Sugar Ray': 'M', 'Ali': 'H' 'Pacquiao': 'L'}
Step by Step Solution
★★★★★
3.42 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
1 Define the function WeightClass that takes a list of dictionaries weightList as a parameter python ...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