(b) Explain what is going on in the following program. def main (file_name): >>> main('') File...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(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) (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)
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
This assignment requires you to complete the 2022 tax reporting for a fictional woman named Anna Smith. Question 1 T1 - step 4 - line 66 This is Anna's taxable income Answer: Question 2 T1 - step...
-
The occupant inside a rotating space habitat of the future feels that she is being pulled by artificial gravity against the outer wall of the habitat (which becomes the "floor"). Explain what is...
-
A nutritionist at the Food and Drug Administration is studying the effects of cereal marketing on family meal choices. In particular, she would like to understand how cereal manufacturers market...
-
How is feed related to speed in machining operations such as turning?
-
Consider a homogeneous system of linear equations in n variables, and suppose that the augmented matrix has rank r. Show that the system has nontrivial solutions if and only if n > r.
-
The pair of pulleys shown in Figure P9.31 is used to lift a \(50-\mathrm{kg}\) block \(0.25 \mathrm{~m}\). The constant acceleration of the block during the lift is \(+2.5 \mathrm{~m} /...
-
Oasis Company has used the dollar-value LIFO method for inventory cost determination for many years. The following data were extracted from Oasiss records. Instructions Calculate the index used for...
-
XYZ Corp. has a bond issue with a $1,000 par value and a 10.42% coupon rate. It pays interest annually and has 19 years remaining to maturity. It just made a coupon payment (i.e., it has 19 coupon...
-
Annual demand for number 2 pencils at the campus store is normally distributed with mean 1,000 and standard deviation 250. The store purchases the pencils for 6 cents each and sells them for 20 cents...
-
2. Charlottetown Manufacturing Inc. borrowed money from Truro Corporation in exchange for a note on January 1, 2021. Charlottetown has a December 31 year end. Other information pertaining to this...
-
What is meant by the term private placement? What are its advantages and disadvantages within the financial markets?
-
Distinguish between the concepts of the maturity-risk premium and the liquidity-risk premium.
-
What is the opportunity cost of funds?
-
Microfinance Company needs to raise $800,000 to improve the position of cash. It has decided to issue a $1,000 par value bond with 15 percent annual coupon rate and 5-year maturity. The investors...
-
What are the key characteristics of an effective financial system?
-
The distributor is so confident of the market that, if Par can make the bags at a competitive price, the distributor will purchase all the bags that Par can manufacture over the next three months. A...
-
QUESTION 9 HC-O-C-R R-C-O-CH HC-O-P-O-CH-CH-NH3* O || O a. Phosphatidic acid, Serine O b. Lysophosphatidic acid, Serine, Free FA O c. Lysophosphatidylserine, Free FA O d. 2 Free FAs, Serine, Glycerol...
-
Which of the following best describes the underlying rationale for a written investment policy statement (IPS)? A. A written IPS communicates a plan for trying to achieve investment success. B. A...
-
Which of the following is least important as a reason for a written investment policy statement (IPS)? A. The IPS may be required by regulation. B. Having a written IPS is part of best practice for a...
-
Which of the following typical topics in an investment policy statement (IPS) is most closely linked to the clients distinctive needs? A. Procedures. B. Investment Guidelines. C. Statement of Duties...
Study smarter with the SolutionInn App