Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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 (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

Step: 1

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Physics

Authors: Paul G. Hewitt

11th edition

321568095, 9780-032166256, 321662563, 978-0321568090

More Books

Students also viewed these Programming questions