Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a python code and no defs, returns, or break Question 3 A frog fell in a dried up well. He tries to get
This is a python code and no defs, returns, or break
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 1! 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.pyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started