Question: python program Question 3 A frog fell in a dried up well. He tries to get out of this well by jumping up the wall,

 python program Question 3 A frog fell in a dried up

python program

Question 3 A frog fell in a dried up well. He tries to get out of this well by jumping up the wall, but sometimes when he jumps up, he lands on a slippery patch and slides back down. Each time the frog jumps, he goes up by 5 metres. Each time the frog lands on a slippery patch, he slides down 3 metres. Given the depth of the well as an integer, calculate the number of tries (jumps) that the frog takes before he gets out of the well. Each time the frog lands on a slippery patch, display a message indicating the jump on which this happened. Please note that if the jump puts the frog at the top of the well, he cannot slide back down. Note: Use the random module and the randint function to randomly generate values between 0 and 1 (inclusive) indicating if the frog has landed on a slippery patch (1) or not (O). See textbook page 165 for an example of random number generation For example, given 30 metres as the well depth, sample input/output from the code is as follows: Enter the depth of the well as an integer: 30 Oops! Slippery patch on jump number 11 Oops! Slippery patch on jump number 2! Oops! Slippery patch on jump number 4! Oops! Slippery patch on jump number 5! Oops! slippery patch on jump number 8! It took the frog 9 tries to come out of the 30 metres deep well. Call the file containing your program frog.py

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!