Question: Here is a little practice using random numbers.First import the random module:import randomNow get a random integer and assign it to the variable n:n =

Here is a little practice using random numbers.First import the random module:import randomNow get a random integer and assign it to the variable n:n = random.randrange(1,10)Now for the hard part.Use a while loop that calls random.randrange(1,10) and compares the result to n. Use a counter to count each time through the loop. When the result equals n, print the following:print(f'got {n} in {counter} attempts!')and break out of the loop. If you don't break out of the loop, your program will not terminate... ever.

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!