Here, I made my first Python game using basic concepts called loops, if-else conditions, and importing random modules, which makes it easier for beginners to execute learning adequately.
Firstly, we have to import a random module and give a range of numbers between 1 and 100 using the randint module.
We assigned a random number to Player 1 and challenged the opponent to guess the number correctly in the fewest number of attempts.
When a guessed number is not equal to the random number, it further determines whether the guessed number is greater or lesser than the random number and asks the user to re-attempt the number according to the condition, like increasing or decreasing the number, utilizing if-else statements and a while loop.
If a user correctly guesses the number, the while loop gets terminated and says ‘Congratulations’.Also, it counts up the number of attempts to guess correctly.
It also shows your level by giving suggestions like ‘You need to improve yourself!’ and ‘You are a pro in the game’ using if-else statements. When a user guesses correctly in less than five attempts, he or she is considered a pro in the game.
In conclusion, this Python guessing game project is a fantastic way for beginners to learn and understand the fundamental concepts of programming. By working on this project, you can get a hands-on understanding of loops, if-else conditions, and the use of random modules. Completing this project will not only boost your confidence but also level up your Python skills. So, start coding, make mistakes, learn from them, and most importantly, have fun. Remember, every expert was once a beginner. Happy coding!
The screenshot and code for the game are pinned below. Just check it out, and if you have any ideas or feedback about this project, feel free to give any suggestions.