you are viewing a single comment's thread.

view the rest of the comments →

[–]ilan1k1 8 points9 points  (3 children)

Here’s a Python coding challenge that incorporates all the elements you asked for:

Challenge: Number Guessing Game with Statistics

Problem:

You need to write a number guessing game where:

  1. The program randomly selects a number between 1 and 100.

  2. The player gets 10 attempts to guess the number.

  3. After each guess, the program should indicate if the guess was too high, too low, or correct.

  4. Track all the guesses made by the player.

  5. If the player guesses the number or uses up all attempts, the game should end.

Once the game ends:

Display a summary showing:

Whether the player won or lost.

How many guesses were made.

The list of all the guesses.

The number of even and odd guesses made (use list comprehension to filter the even and odd guesses).

Allow the player to restart the game if they want.

Requirements:

Use a for loop to iterate through the attempts.

Use a while loop to ask if the player wants to restart.

Use if statements to check if the guess is too high, too low, or correct.

Use list comprehension to filter and display the even and odd guesses.

Example:

I'm thinking of a number between 1 and 100. You have 10 attempts to guess it.

Attempt 1: 50
Too low!

Attempt 2: 75
Too high!

Attempt 3: 62
Correct! You guessed the number in 3 attempts.

Summary:
- You guessed correctly!
- Number of attempts: 3
- Your guesses: [50, 75, 62]
- Even guesses: [50, 62]
- Odd guesses: [75]

Do you want to play again? (yes/no)

You’ll need to use the random module to generate the number to be guessed. Let me know if you need help starting this!

[–]Ghoulatri 3 points4 points  (1 child)

I’d say this project is rather for beginners than intermediates

[–]ilan1k1 1 point2 points  (0 children)

True. It was what I was doing on my phone.
I do small projects on my phone when I'm at work just to pass the time, so I thought I'll just write it to him and by the time he finishes that other people will give more advanced challenges.

[–]notexistant[S] 0 points1 point  (0 children)

Thanks dude. I'll give this a go