Question: Write a Python program to randomly sets a target number in the range (1, N), and the user will guess the target. The user has
Write a Python program to randomly sets a target number in the range (1, N), and the user will guess the target. The user has a maximum number of guesses (m). When the guess is wrong, the program lets the user know whether the guess was higher or lower than the target. When the user wins with g guesses a statement is printed:
g< m//3 then print Excellent
m//3<= g <2m>
g>= 2m/3 then print OK
If the user couldnt guess correctly with m guesses print Game is over
Whenever the user types in quit (any letter lower or upper case), print Game is over and the program terminates.
You should use the random module by the following command at the beginning of your program:
import random
Then whenever you want to create a random number you can use the following command:
target = random.randint(1, N)
where (1, N) is the range of numbers from which the random number is chosen.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
