Question: Python. Random Number Guessing Game. Objectives : Practice random number generation, loop, and decision structures. Design a Python program that generates a random number in

Python. Random Number Guessing Game.

Objectives:

Practice random number generation, loop, and decision structures.

Design a Python program that generates a random number in the range of 1 through 100 (inclusively), and asks the user to guess what the number is. Keep that number hidden from the user. If the users guess is higher than the random number, the program should display Too high, try again. If the users guess is lower than the number, the program should display Too low, try again. If the users guess matches that hidden random number, the program should congratulate the user and then display the number of guesses that the user makes.

You will need to use a function from the random module to generate a random number.

User interface specifications:

Input

o The program prompts users to enter guesses. Clearly tell users that their input number must be in the range [1, 100]; i.e., from 1 to 100 inclusively.

Output

o Feedbacks to users about their guesses, as specified in the first paragraph of this assignment sheet.

Code specifications:

The first comment line contains the name of the script file you submitted for grade.

The header comment lines at the top of the file contain a brief description of the program. The description should be one or 2 lines long describing the purpose of the program.

Partition the task into smaller subtasks and implement each subtask with function(s). Each function must have comment lines describing its functionality, inputs, and outputs, as applicable.

Your program must have a main function to aggregate the decomposed subtasks as shown in the loan example in class. You also have to include comment lines in your main function to describe the logic or flow of your solution to the whole problem.

Finally, dont forget to use the following idiom to call your main function within your program.

if __name__ == "__main__":

main()

Use descriptive variable names and function names.

 Python. Random Number Guessing Game. Objectives: Practice random number generation, loop,

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!