The “Number Guessing Game” is an engaging Python program that challenges the player to guess a randomly generated number within a specified range. In this game, the player has the option to choose between two difficulty levels: “Easy” and “Hard.” The primary objective is to guess the secret number with a limited number of attempts, promoting strategic thinking and problem-solving. Below is a detailed program description:

Game Rules:

  1. The program generates a random number between 1 and 100.
  2. The player chooses a difficulty level:
    • “Easy” level allows the player 10 lives (guesses).
    • “Hard” level allows the player only 5 lives (guesses).
  3. The player attempts to guess the secret number within the allotted lives.
  4. After each guess, the program provides feedback on whether the guessed number is higher or lower than the secret number.
  5. The game continues until the player either guesses the correct number or exhausts all allowed attempts.

Program Features:

  1. Initialization: The program initializes the game by selecting a random number within the specified range and setting the initial number of attempts based on the chosen difficulty level.
  2. User Interaction: The player interacts with the program through the console. They choose a difficulty level and enter their guesses.
  3. Input Validation: The program ensures that the player’s input is valid, rejecting non-numeric entries and guesses outside the specified range.
  4. Game Logic: The core of the program is the game logic that compares the player’s guesses with the secret number and provides feedback. It also keeps track of the number of lives remaining.
  5. Outcome: The game ends when one of the following conditions is met:
    • The player correctly guesses the secret number.
    • The player exhausts all allowed lives without guessing the secret number.
  6. Feedback: At the end of the game, the program provides feedback, including whether the player won or lost, the actual secret number, and the number of lives used

Day 12 : Solution Number Guessing Game

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *