Project #03: How to code Number Guessing Game (Advanced Version) | Python Programming for Beginners

preview_player
Показать описание
In this project, you'll write a program in which:
- Computer will generate a random number in a pre-defined range
- User attempts to guess the number within certain number of times

We use if else conditions to check the difference between user's guess and number, then give hint to user. Hints are different based on how different user's guess and the number is.

In this video, you'll see a lot of nested if... else ... conditional statement, while loop and when to break the loop, and a lot of f-strings usage to output values of variables.

Besides, you need to do user input validation to make sure user to enter valid input data

-------------------------
Python Coding for Beginners
Python Programming for Beginners
Learn Python by Building Projects
Python Exercises and Practical Examples with solutions
Practice Python Online with solution
How to write a Python program
Рекомендации по теме
Комментарии
Автор

You can modify and upgrade this game like this: you play against computer. You have a number like computer and both you and computer guess the other's number. Who gets it right first is the winner. Or if you have any idea to make the solution better, please share your code or leave a comment.

makeeverydayezday
Автор

This seems awesome so far, can't wait to start learning more! I've been wanting to start programming for a while now but this is the video that really pushed me to start.

andrewpotter
Автор

Thank you for your video... I literally have a school project I need to submit tomorrow and your video has helped a lot. Thanks💚

tsudashiro
Автор

this is a good explanation for beginners, while a lot of other material out there (and even some teachers) glosses over the basic stuff. having it spelled out and then repeated allows for much more retention.

techietechie
Автор

Good explanation and good code, nice job. I will try to make the same program but in tkinter python GUI module.

mukjunghee
Автор

Very helpful video, thank you! I was wondering, If I would like to ask the player if they wanna play again. How would I go about that?

MaiaEmmero
Автор

I get a error trying your code: "max_guesses" is not defined. I can also find it just once in your code, in line 39.

kristnajohanna
Автор

Write a program in Python for the following numerical game with additional features:
 The computer stores a random number between 1 and 100.
 The player (user) attempts to guess the number.
 The player has a total of five attempts.
 After each wrong guess, the computer tells the user if the number was too high or too
low.
 If the fifth attempt is also wrong, the number is output on screen.
 The player wins if he or she can guess the number within five attempts.
 The player is allowed to repeat the game as often as he or she wants.
 Track the number of games played and the number of wins.
 Provide an option to view the game statistics (number of games played, number of wins,
and win percentage).
 Implement input validation to ensure the user enters a valid number within the specified
range.
 Use object-oriented principles: Create classes for the game logic, player statistics, and
user interface.
 Add exception handling to manage unexpected errors.

SYDNEYMALAMA-rh