Exercise 2: Guess the Number Game
Exercise 2: Guess the Number Game
Write a Python program for a “Guess the Number” game. Implement the following:
- Function: `generate_random_number(min_value, max_value)`
– This function generates and returns a random integer between `min_value` and `max_value`, inclusive.
- Procedure: `play_guessing_game()`
– In this procedure, the program should choose a random number between 1 and 100 using the `generate_random_number()` function.
– The user should be prompted to guess the number, and the program should provide feedback (higher, lower, or correct) based on the user’s input.
– The user should continue guessing until they guess the correct number.
– Once the user guesses the correct number, the program should display the number of attempts it took to guess correctly.
In the main part of the program, call the `play_guessing_game()` procedure to start the “Guess the Number” game. Allow the user to play multiple times if they wish.