Question: Please help with testing for this python program, will rate a thumbs up: For the code below add tests for the find_most_efficient function using the
Please help with testing for this python program, will rate a thumbs up:
For the code below add tests for the find_most_efficient function using the doctest approach


Thank you!
2 3 = + = 10 12 33 14 def calc_efficiency (line_str, the_dict): ""Calculate player efficiency. fields_list = line_str.split(',') first_name fields list (1) last_name = fields_list [2] # mapping fields in a line to their particular variable. # league is a ser everything else an int leag, gp,mins,pts, oreb, dreb,reb, asts, st1, blk, to, pf, fga, fgm, fta, ftm, tpa, tpm = fields_list[3], int (fields_list [4]), int(fields_list [5]), int(fields_ list[6]), int(fields_list [7]), int (fields_list [8]), int (fields_list [9]), int (fields_list[10]), int(fields_list [11]), int(fields_list [12]), int(fields_list [13] ). int(fields_list [14]),int(fields_list [15]), int(fields_list [16]), int(fields_list [17]), int (fields_list [18]), int(fields_list[19]), int(fields_list [20]) # calculate the player's efficiency efficiency = ((ptstrebtasts+stl+bik) - ((fga-fgm) + (fta-ftm) +to))/gp the_dict [last_name+first_name] = {' first':first_name, 'last'.last_name, 'league':leag, 'mins' :mins, 'op':gp, 'pts':pts, 'oreb':oreb, 'dreb'dreb, 'reb':reb, 'asts': asts, 'stl':sti, 'blk':blk, 'to':to, 'fga':fga, 'fgm': fgm, fta':fta, 'Etm' :ftm,'tpa':tpa,' tpm': tpm, 'efficiency' :efficiency} - def find_most_efficient (the_dict, how_m return list of tuples (efficiency, name) from dictionary how_many is number of muples to gather' # user must implement return 1] 16 18 19 20 = 21 23 24 2 21 30 31 12 * def print_results (1st): pretty print the results print('The top () players in efficency are format (len (1st))) print("*1*20) 35 *** main program as a function def main (file_name) : nba_file = open(file_name) 43 nba_dict={} for line_str in nba_file: calc_efficiency (line_str, nba_dict) results_list find_most_efficient (nba_dict, 20) print_results (results_list) nba_file.close() =
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
