Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Phyton Homework Due @5PM need help repl,it Random Gan back to classroom run | # Random 2a) Pull the code from the right panel together

Phyton Homework Due @5PM need help image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
repl,it Random Gan back to classroom run | # Random 2a) Pull the code from the right panel together here 2 # Random 2b) Add messages to the while loop that print out the 3 # new race position for each runner 4 # set up initial values for runners and finish line 7 8 # while loop for gameplay that moves players forward 10 11 # determine winner and print winning mrssage Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.21 on linux the fi ube repl.it- Random Game Part 2 n Game- Part 2 88 talk my repls e game jam Chosenon.. Due: Mar 17,2019 11:59 pm Instructions from your teacher Random Game Part 2 submit he starting a game taking turns and keeping score . ending a game Imagine we're building a simple game where we have two runners competing in a race. They both begin at the starting line. They each take a turn running some distance. To keep this simple, we'll have them run a fixed number of steps in each turn. The first one to reach the finish line wins So what do we need to know? What do we need to keep track of? Starting a game Let's assume the starting line is at step 0. We have two runners to keep track of, so we'll want a variable for pach's race position. We'll start each at step 0. runneri 0 runner20 We also need to know at which point someone has won. Where is the finish line for the race? Let's set the finish line at step 100. finish 100 Taking turns and keeping score To get from the starting line at step 0 to the finish line at step 100, the runners need to move forward repeatedly First runnerl will move forward. Let's say they run at a pace of 5 steps per t each time we'll add 5 to their race position. runner! += 5 gafalk my repls chosenon.. game jam Due: Mar 17, 201911:59 pm submit Instructions from your teacher Taking turns and keeping score To get from the starting line at step 0 to the finish line at step 100, the runners need to move forward repeatedly First runnerl will move forward. Let's say they run at a pace of 5 steps per turn. So each time we'll add 5 to their race position. runner1+5 Then runner2 will move forward. Let's say they run at a pace of 4 steps per turn. So each time we'll add 4 to their race position. runner24 Since these are repeated aetions, they will o inside a loop for gameplay. Ending a game The end of the game is determined by the end condition for the loop for gameplay Basically, while neither runner has reached the finish line, we keep the loop running so that the runners move forward. while runnerl = finish: print("Runner 1 wins") else: print("Runner 2 wins") Exercises Random-2a) Put all the steps listed above together in the code window. Random-2b) Add messages inside the while loop that print out the new race position for each runner. For example print( "Runner 1 is now at step", runner1) Pivacy Terms

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Students also viewed these Databases questions