Day #4 || snake, water, gun game using python|| Python practice programs || codeandman🔥🔥😊😊❤️❤️[source code]
Hello what’s up guys today in this post I am going to give you the source code of my video called Day 4 || Python practice Programs so let’s begin:
So guys in this video we have made snake, water, gun game so if you haven’t watched this video then do watch it and tell me in the comment section that what kind of projects should I bring in the future?. Also like the video so that I can help more people. If you haven’t subscribed my channel then do subscribe for latest updates. Now let’s see the source code :
Here’s the complete source code :
# # snake, water, gun game using python
# # import random
# # b = ['snake','water','gun']
# # a=random.choice(b)
# # print(a)
# # Coding of the game starts from here
# import random
# user = input("Enter Your choice:")
# l1 = ['snake','water','gun']
# comp = random.choice(l1)
# print("Comp:",comp)
# print("User:",user)
# if user == "snake" and comp == "water":
# print("You Won!")
# elif user == "water" and comp == "snake":
# print("You Lose!")
# elif user == "water" and comp == "gun":
# print("You Won!")
# elif user == "gun" and comp == "water":
# print("You Lose!")
# elif user == "snake" and comp == "gun":
# print("You Lost!")
# elif user == "gun" and comp == "snake":
# print("You Won!")
# elif user == comp:
# print("You both chosen the same!")
# else:
# print("Please Check your choice and try again!")
# SNAKE WATER AND GUN
import random
uchoice = input("Enter your choice:")
l1 = ["snake","water","gun"]
cchoice = random.choice(l1)
print("comp:",cchoice)
if uchoice == "snake" and cchoice == "gun":
print("You Lost!")
elif uchoice == "gun" and cchoice =="snake":
print("You Win!")
elif uchoice == "snake" and cchoice == "water":
print("You Win!")
elif uchoice=="water" and cchoice =="snake":
print("You Lost")
elif uchoice == "water" and cchoice == "gun":
print("You Win!")
elif uchoice =="gun" and cchoice == "water":
print("You Lost!")
elif uchoice == cchoice:
print("You both chosen the same!")
else:
print("Check Your choice and try again!")
The Logic
In this program we have made a input in which the user will enter his call and after that we have generated a random string from a list and assigned it as the computer’s call and after that we have checked the conditions with the help of the if else ladder. According to the winner we have wrote you win! And according to the lose we have written that you lost!.
I hope that you liked this program.
Thank You.
Don’t forget to like share and subscribe my video.
Comments
Post a Comment