Question: Page 1 Python Exercise 5 Tortoise vs. Hare (60 pts) Write a program that simulates the classical race between the tortoise and the hare with




Page 1 Python Exercise 5 Tortoise vs. Hare (60 pts) Write a program that simulates the classical race between the tortoise and the hare with a couple modifications) The tortoise and hare will race in a 'course of 50 spaces. Each animal starts at the 'starting line which is position 1 (i.e. the left most part of the output). The finish line is at space 50, and the first animal to reach or pass 50 wins the race and the prize (a pail of fresh organic lettuce and carrots). In this program, the course is up the side of a slippery mountain, so the animals can occasionally lose ground. Each animal has specific move types that correspond to their movement in the course. The animal, move type, probability of move type and actual move is shown in the table below: Animal Move Type Probability of Move Actual Move Tortoise Fast Plod 50% 3 spaces forward Slip 20% 5 spaces backward Slow Plod 30% 1 space forward Hare Sleep 20% No movement Big Hop 20% 7 spaces forward Big Slip 10% 10 spaces backward Small Hop 30% 1 space forward Small Slip 20% 2 spaces backward The race is managed by a 'clock (loop) that ticks once per 'second' (iteration). While the race has not been won, your program should adjust the position of the tortoise and the hare on the course, with each tick of the clock (i.e., iteration in the loop). The race (ie, loop) ends when one or both of the animals reaches the 50' space. The program should use variables to keep track of the animal's positions (between 1 and 50). If an animal slips at the start of the race, move the animal back to position 1. Similarly, if an animal advances past the finish line, rest the position to 50. The movements of each animal should be controlled by a function that accepts one argument and returns one value. The value passed to the function should represent an initial or current position in the race and the value returned should represent the animal's new position in the race MacBook Air VULLUSTO Page
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
