Welcome all
Snake, water, and Gun Game is a very simple game that children usually play in a group of 2. The project we are going to make in this tutorial is where your partner is your system and you are going to enjoy this game with your system. Did it sound interesting? If you are a beginner with python then, It is the best kickstart towards improving python programming by implementing beginner and small python projects.
Table of Contents
so, let's get started.
Understanding The Problem
In this project, you are player 1 and your partner is your system. you have 3 choices to play the game that is Snake, Water, and Gun. You have to take a random choice of the computer from these 3 options and you too have to choose one.
And then we have to compare both the choices and mark the score whoever wins. The cases for winning will be as follows.
- Snake drinks the water (snake win)
- Gun will sink in water (water win)
- Gun will kill the snake (Gun win)
We will use the random module to make random choices from the computer side.
Making The Project more Interesting
Only making a simple application will not excite you so let's add some additional features to our application that attracts any user to play it multiple times. So, along with the main function like to choose between 3 options and compare them is it also possible that if the game has been played multiple times without stopping, then print the total number of times the game has played, as well as how many times the user wins and loses with several draws.
Implementation
Code:
Now, the final step is to print how many times a user has played and the number of times he wins loses, and match draws. The results will print when the game ends mean the code will come out of while loop
🔖 For the full source code visit: snake water gun game in python
CONCLUSION
That's the end of a project. Hope you enjoyed it. It is a very simple program to let you understand the basic concepts of the random module and how it is used. In our further article, we will be building projects with many advanced concepts and projects with databases and all.
This is a simple project you can place in your GitHub profile to show anyone your python repository and collection of nice codes. If you are familiar with the Python random module, then the project is very simple for you and can make within a few minutes.
Keep learning, Happy Learning 😊😊
Awesome..
ReplyDelete