Question: (b) Explain what is going on in the following program. def main (file_name): >>> main('') File named not found >>> main('x') Traceback (most recent

 (b) Explain what is going on in the following program. def main 

(b) Explain what is going on in the following program. def main (file_name): >>> main('') File named not found >>> main('x') Traceback (most recent call last): raise IOError('bad file format.') IOError: bad file format. >>> main('player_career.csv') The top 10 players in efficency are ********** Wilt Chamberlain 41.50 Bill Russell : 31.71 Oscar Robertson 31.61 Bob Pettit 31.11 Kareem Abdul-jabbar : 30.93 Larry Bird: 29.77 Elgin Baylor : 29.74 Michael Jordan 29.19 try: Magic Johnson 29.10 Charles Barkley 28.16 nba file open (file_name) except IOError: print (File named not found'.format (file_name)) else: nba_dict={} line strnba_file.readline () if line str[0:5] !-'ilkid': raise IOError ('bad file format.') for line_str in nba file: calc efficiency (line_str, nba_dict) results list find most efficient (nba_dict, 10) print results (results_list). nba file.close(). if name -- '_main_': import doctest doctest.testmod() (c) What is the purpose of doctest and how does it work? (9 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer The provided program seems to be designed to process a file containing NBA player data and identify the top 10 players based on efficiency Lets ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!