You are on page 1of 20

A PROJECT

“SNAKE
WATER
AND GUN
GAME
IN PYTHON”
Acknowledgement
The success and final outcome of this project required a lot of
guidance and assistance from few people and we are
extremely fortunate to have got this all along the completion of
our project work. Whatever we have done is only due to such
guidance and assistance and we would not forget to thank
them.

We respect and thank Mrs. Archana Rai, for giving us an


opportunity to do the project work and providing us all support
and guidance which made us complete the project on time. We
are extremely grateful to her for providing such a nice support
and guidance though she had busy schedule managing the
school affairs.

We owe our profound gratitude to her, who took keen interest


on our project work and guided us all along, till the completion
of our project work by providing all the necessary information
for developing a good system.

We would not forget to remember her, for unlisted


encouragement and more over for her timely support and
guidance till the completion of our project work.

We are thankful and fortunate enough to get constant


encouragement, support and guidance from Principal sir- Mr.
G.K. Udgata and all Teaching staffs of Department of computer
science who helped us in successfully completing our project
work. Also, we would like to extend our sincere regards to all
the non-teaching staff of department of computer science for
their timely support.

Ayush Sahu and Sanskar Sahu

CERTIFICATE
The project recorded in the file has

been satisfactorily performed by

Sanskar sahu and Ayush sahu,

studying in class Xl Science of DAV

BORL Public School during the

academic year 2020-21.

Teacher’s Signature Principal’s Signature


Date School Stamp

LOGIC
This game involves two players.
In which one give input, i.e.
snake, water and gun and
computer guesses random among
snake, water and gun.
●If input is snake and computer
guesses gun then computer wins
and we lose or vice-versa.
●If input is water and computer
guesses gun then we won and
computer lose or vice-versa.
●If input is gun and computer
guesses gun then match tied.
FLOWCHART
START

PRINT INSTRUCTION

GENERTE RANDOM
CHOICE

GET GUESS FROM


USER

IF
GUESS=
RANDOM PRINT “GAME
CHOICE TIED”

A B
B
A

IF GUESS
>RANDOM PRINT “YOU GETS
1 POINT”
CHOICE

IF GUESS PRINT
<RANDOM “COMPUTER
CHOICE GOT 1
POINT”

IF YOUR
POINTS >
COMPUTER
POINTS
PRINT YOU WIN!

PROGRAM CODE END

print(" \t\t\t ▶Welcome to Snake, Water and


Gun game◀\n\n")
import random
attempts= 1
your_point=0
computer_point=0
while (attempts<=7):
lst=["snake","water","gun"]
ran=random.choice(lst)
print("→ What do you choose snake, water
or gun:-")
inp=input()

if inp==ran:
print(f"you choose {inp} and computer
guess is {ran}")
print("Match Tied, Nobody gets point.\
n")

elif inp=="snake" and ran=="water":


your_point=your_point+1
print(f"you choose {inp} and computer
guess is {ran}")
print("You won this round, you got 1
point.\n")

elif inp=="water" and ran=="snake":


computer_point = computer_point + 1
print(f"you choose {inp} and computer
guess is {ran}")
print("You lost this round, computer got
1 point.\n ")

elif inp=="water" and ran=="gun":


print(f"you choose {inp} and computer
guess is {ran}")
your_point=your_point+1
print("You won this round, you got 1
point.\n")

elif inp == "gun" and ran == "water":


print(f"you choose {inp} and computer
guess is {ran}")
computer_point = computer_point + 1
print("You lost this round, computer gets
1 point.\n ")

elif inp == "gun" and ran == "snake":


print(f"you choose {inp} and computer
guess is {ran}")
your_point=your_point + 1
print("You won this round, you got 1
point.\n")

elif inp == "snake" and ran == "gun":


print(f"you choose {inp} and computer
guess is {ran}")
computer_point=computer_point+1
print("You lost this round, computer got
1 point.\n")

else:
print("invalid, Try again\n")

print(7- attempts, "no. of guesses left")


attempts = attempts + 1

if attempts>7:
print("Game Over")
print(f"your point is {your_point} and
computer point is {computer_point}.")

if computer_point == your_point:
print("Match tied.")
if computer_point > your_point:
print("Computer won and you lost.")
if computer_point < your_point:
print("HURRAY! YOU WON")
Output - 1
▶Welcome to Snake, Water and Gun
game◀

→ What do you choose snake, water or


gun:-
water
you choose water and computer guess is
gun
You won this round, you got 1 point.
6 no. of guesses left
→ What do you choose snake, water or
gun:-
water
you choose water and computer guess is
gun
You won this round, you got 1 point.

5 no. of guesses left


→ What do you choose snake, water or
gun:-
snake
you choose snake and computer guess is
water
You won this round, you got 1 point.

4 no. of guesses left


→ What do you choose snake, water or
gun:-
gun
you choose gun and computer guess is
water
You lost this round, computer gets 1 point.

3 no. of guesses left


→ What do you choose snake, water or
gun:-
gun
you choose gun and computer guess is
snake
You won this round, you got 1 point.

2 no. of guesses left


→ What do you choose snake, water or
gun:-
snake
you choose snake and computer guess is
gun
You lost this round, computer got 1 point.

1 no. of guesses left


→ What do you choose snake, water or
gun:-
snake
you choose snake and computer guess is
gun
You lost this round, computer got 1 point.

0 no. of guesses left


Game Over
your point is 4 and computer point is 3.
HURRAY! YOU WON

Output - 2
▶Welcome to Snake, Water and Gun
game◀

→ What do you choose snake, water or


gun:-
snake
you choose snake and computer guess is
water
You won this round, you got 1 point.

6 no. of guesses left


→ What do you choose snake, water or
gun:-
water
you choose water and computer guess is
snake
You lost this round, computer got 1 point.

5 no. of guesses left


→ What do you choose snake, water or
gun:-
33
invalid, Try again

4 no. of guesses left


→ What do you choose snake, water or
gun:-
water
you choose water and computer guess is
snake
You lost this round, computer got 1 point.

3 no. of guesses left


→ What do you choose snake, water or
gun:-
gun
you choose gun and computer guess is gun
Match Tied, Nobody gets point.
2 no. of guesses left
→ What do you choose snake, water or
gun:-
snake
you choose snake and computer guess is
snake
Match Tied, Nobody gets point.

1 no. of guesses left


→ What do you choose snake, water or
gun:-
gun
you choose gun and computer guess is
water
You lost this round, computer gets 1 point.

0 no. of guesses left


Game Over
your point is 1 and computer point is 3.
Computer won and you lost.

TOPICS COVERED
IN THIS PROJECT

▹Import statements
▹While statements
▹if, else statements
▹Conditions
▹Comparison operators
▹Difference between
“=”and “==”

REFERENCES

1. NCERT of Class XI
Computer Science.

2. Computer Science with


Python by Sumita Arora.

You might also like