Write a Python function to read players' names and scores from a file into two parallel...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python function to read players' names and scores from a file into two parallel lists, a list of names and a list of scores, which will be used during the game. While reading the file, your function keeps track of the best score read so far, along with the name of the player who got that score. After reading all of the names and scores, your function displays the highest score and that player's name. For instance, if Karin had the best score and her score was 5970, your function would display: Karin has the best score: 7212 Here's an example file: Michael 4999 Chris 5970 Madeleine 4110 Karin 7212 Strip off the newline character before adding a name to the list of names. Assume that the filename is given when the function is called, so do not ask the user for a filename. Also, assume that the two lists are initially empty and that all scores are different: there are no ties. Here is the header line for the function: def readFile(fileName, nameList, scoreList): ****** Opens and reads fileName into two parallel lists: nameList and scoreList. Also, determines and displays the highest score, and that player's name Assumes file is in correct format: name, score, name, with each name and each score on a separate line in the file Assumes that nameList and scoreList are initially empty Assumes that all scores are different: there are no ties * * * *** Write a Python function to read players' names and scores from a file into two parallel lists, a list of names and a list of scores, which will be used during the game. While reading the file, your function keeps track of the best score read so far, along with the name of the player who got that score. After reading all of the names and scores, your function displays the highest score and that player's name. For instance, if Karin had the best score and her score was 5970, your function would display: Karin has the best score: 7212 Here's an example file: Michael 4999 Chris 5970 Madeleine 4110 Karin 7212 Strip off the newline character before adding a name to the list of names. Assume that the filename is given when the function is called, so do not ask the user for a filename. Also, assume that the two lists are initially empty and that all scores are different: there are no ties. Here is the header line for the function: def readFile(fileName, nameList, scoreList): ****** Opens and reads fileName into two parallel lists: nameList and scoreList. Also, determines and displays the highest score, and that player's name Assumes file is in correct format: name, score, name, with each name and each score on a separate line in the file Assumes that nameList and scoreList are initially empty Assumes that all scores are different: there are no ties * * * ***
Expert Answer:
Answer rating: 100% (QA)
def readscoresfilename Initialize empty lists to store names and scores names score... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
8. (a) Give a combinatorial proof that n - (x + 1) = (*) + ("=) k (b) Give a combinatorial proof that + + k (*) k k k.2 == +2 2 (c) Use Parts (a) and (b) to prove 12+22+ +n n(n + 1)(2n + 1) = 6 (This...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A group of five successful business people were awarded the franchise for one of two new expansion teams in the North American Sports League (NASL). The professional sports franchise was named the...
-
Consider the following chair conformation of bromocyclohexane: (a) Identify whether the bromine atom occupies an axial position or an equatorial position in the conformation above. (b) Draw a...
-
An electron is bound in a square well of width 1.50 nm and depth U0 = 6E. If the electron is initially in the ground level and absorbs a photon, what maximum wavelength can the photon have and still...
-
Does drying barley seeds in a kiln increase the yield of barley? A famous experiment by William S. Gosset (who discovered the t distributions) investigated this question. Eleven pairs of adjacent...
-
Graph the expectation function for the logistic growth model (12.34) for \(\theta_{1}=10, \theta_{2}=2\), and values of \(\theta_{3}=0.25,1,2,3\), respectively. Overlay these plots on the same set of...
-
Astrid, who is single, is a sales representative for several sporting goods manufacturers. She operates her enterprise as a sole proprietorship. Astrid has one employee, Melvin, who serves as office...
-
Write a C++ program using the selection statements if else, if else if, and switch to show the description of the quality of a service. Services are rated from 1 to 5 stars: 5 is excellent, 4 is very...
-
Exercise 6.1 Configuring Memory on Paper Objective: a computer is not performing as well as it used to. Windows 10 tool would the technician get the user to open to quickly tell how much RAM is...
-
2. An air parcel rises from the surface to 5.0 km The surface temperature is 31 C, dew point 23 C, anc pressure 1010mb. Table 2 lists the measured temperature of the surrounding atmosphere through...
-
Franchising has certainly become a key component of the Canadian economy. What do you see as the major advantages and disadvantages of franchising?
-
Discuss whether you personally agree with the majority opinion or with the dissenting justices in the Texas and explain why.
-
What other trends do you think we'll see in the next 25 years that will affect business? Find an article about an interesting trend and share it here with your insights.
-
Explain what an asset purchase of a business is and what a stock purchase of a business is. What are the differences between the two.
-
Placing an exact dollar amount on the value of a business may be quite difficultbut not impossible. Certain tangible assetsvehicles, machinery, inventory, and so forthmay be fairly easy to value....
-
An analyst is interested in calculating the cash price of a bond. He is analyzing a 10,000 USD, five-year bond redeemable at par and bearing interest at 6.5% payable semi-annually. The bond is...
-
Consider the function f and its graph. a. Estimate the zeros of the area function b. Estimate the points (if any) at which A has a local maximum or minimum. c. Sketch a graph of A, for 0 x 10,...
-
What is meant by contingent consideration and how is it accounted for?
-
The Roger family lost everything in a fire in their home at the beginning of December 2012. On December 23, 2012, a fundraiser was held and an anonymous donation was made to the Sunworld charity to...
-
The Introduction to Public Sector Accounting Standards in the CICA PSA Handbook sets out the accounting standards applied by various types of government organizations. The sources of generally...
-
Consider a Poisson regression. Let \(e_{i}=y_{i}-\widehat{\mu}_{i}\) denote the \(i\) th ordinary residual. Assume that an intercept is used in the model so that one of the explanatory variables...
-
a. Assume that \(y_{1}, \ldots, y_{n}\) are i.i.d. with a negative binomial distribution with parameters \(r\) and \(p\). Determine the maximum likelihood estimators. b. Use the sampling mechanism in...
-
For the data in Table 12.1, confirm that the Pearson statistic in equation (12.3) is 41.98 . Table 12.1 (12.3) Count Observed (j) (nj) Fitted Counts Using the Poisson Distribution (np;) 01234 6,996...
Study smarter with the SolutionInn App