While digging through a box of very old handheld game consoles, you find one that piques...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
While digging through a box of very old handheld game consoles, you find one that piques your interest. Wondering how it works, you access the source code and find a text file named game.txt full of instructions, one per line. Each instruction consists of an operation (coin, jump, or none) and a signed number (like +25 or - 3). You quickly figure out that coin increases or decreases a value that stores the number of coins earned by the player, jump will jump to a new instruction relative to itself, and none does absolutely nothing. After executing a coin or none operation, the instruction immediately below is executed next. However, jump +2 would continue to the instruction 2 lines below it, and jump-5 causes the instruction 5 lines above to be executed next. The program ends when it attempts to execute an instruction immediately after the last instruction in the file. Based upon Dr. Keyser's Original and Dr. Fullerton's Revision 1 Lab: Topic 11 (individual) Write a program named count_coins.py that opens the game file (game.txt), executes the instructions, and creates a new file named coins.txt that contains only the numbers of coins gained or lost in the order the program is executed. Have your program output the total number of coins earned using the example output below. You do not have to submit your coins.txt file to zyBooks. Example output: Total coins collected: ??? Example coins.txt file created by your program: 29 Revised Fall 2022 SNR -87 4 8 While digging through a box of very old handheld game consoles, you find one that piques your interest. Wondering how it works, you access the source code and find a text file named game.txt full of instructions, one per line. Each instruction consists of an operation (coin, jump, or none) and a signed number (like +25 or - 3). You quickly figure out that coin increases or decreases a value that stores the number of coins earned by the player, jump will jump to a new instruction relative to itself, and none does absolutely nothing. After executing a coin or none operation, the instruction immediately below is executed next. However, jump +2 would continue to the instruction 2 lines below it, and jump-5 causes the instruction 5 lines above to be executed next. The program ends when it attempts to execute an instruction immediately after the last instruction in the file. Based upon Dr. Keyser's Original and Dr. Fullerton's Revision 1 Lab: Topic 11 (individual) Write a program named count_coins.py that opens the game file (game.txt), executes the instructions, and creates a new file named coins.txt that contains only the numbers of coins gained or lost in the order the program is executed. Have your program output the total number of coins earned using the example output below. You do not have to submit your coins.txt file to zyBooks. Example output: Total coins collected: ??? Example coins.txt file created by your program: 29 Revised Fall 2022 SNR -87 4 8
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
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...
-
Establishing causality is difficult, whether conclusions have been derived inductively or deductively. (a) Explain and elaborate on the implications of this statement. (b) Why is ascribing causality...
-
It takes 15 s to raise a 1200-kg car and the supporting 300-kg hydraulic car-lift platform to a height of 2.8 m. Determine (a) The average output power delivered by the hydraulic pump to lift the...
-
Answer these questions, based on the debit memorandum shown here. 1. Which company is returning the merchandise? 2. How many items are being returned? 3. What amount is entered in the journal entry?...
-
Crystal Clean Ltd produces a dishwashing liquid. At the beginning of January, 63 000 litres of liquid cleaner were in process, 100% complete as to raw materials and 40% complete as to conversion...
-
Payout Ratio and Book Value per Share Divac Company has developed a statement of stockholders equity for the year 2010 as follows: Divacs preferred stock is $100 par, 8% stock. If the stock is...
-
What are the key considerations in the design and optimization of extraction processes for the recovery of valuable metals from ores and industrial waste streams, with a focus on factors affecting...
-
A manufacturer has acquired four small assembly plants, located in Charlotte, Tulsa, Memphis, and Buffalo. The plan is to remodel and keep two of the plants and close the other two. The table at the...
-
Keiser's research among the Khoistani focused on the roles of women in the community True False
-
How do you identify use cases? Where do you look to find the use cases? What are good sources of use case mining?
-
When is include relation used?
-
What is actor generalization?
-
What is the difference between gross domestic product (GDP) and gross domestic income (GDI)?
-
Inheritance relationships are represented in the UML notation by (a) nesting of classes (b) lines with a solid diamond at one end (c) lines with a hollow diamond at one end (d) lines with a...
-
Suppose, household color TVs are replaced at an average age of = 8.2 years after purchase, and the (95% of data) range was from 6.2 to 10.2 years. Thus, the range was 10.2 6.2 = 4.0 years. Let x be...
-
Players A, B, and C toss a fair coin in order. The first to throw a head wins. What are their respective chances of winning?
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
Jason and Mary Wells, friends of yours, were married on December 30, 2012. They know you are studying taxes and have come to you with a question concerning their filing status. Jason and Mary would...
-
Scott Butterfield is self-employed as a CPA. He uses the cash method of accounting, and his Social Security number is 644-47-7833. His principal business code is 541211. Scott's CPA practice is...
-
What is the difference between real objects and virtual objects? Give an example for each.
-
Give a superclass for the following three classes: car, airplane, tank.
-
How do business classes differ from utility classes? Provide one example for each.
Study smarter with the SolutionInn App