Question: While digging through a box of very old handheld game consoles, you find one that piques your interest. Wondering how it works, you access

While digging through a box of very old handheld game consoles, you 

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this task you can follow these steps 1 Open the input file gametxt in read mode and the out... 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!