Skip to main content

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

Popular posts from this blog

How to create a Personal Portfolio website [source code]

  Hey guys how are you all today in this post I am going to give you the source code of my portfolio website’s part 1st video so let’s begin with this post:- Source code of Index.html file:- <DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Gautam Sharma</title> <link rel="stylesheet" href="../CSS-Files/style.css"> <link rel="stylesheet" href="../CSS-Files/utils.css"> </head> <body> <header> <nav> <li><a href="./index.html">Home</a></li> <li><a href="./Contact.html">Contact</a></li> <li><a href="./Haier.html"

Step by step guide to coding a game in Python

  How to Code a Simple Game in Python Python is a powerful and versatile programming language that can be used for a wide range of applications, including game development. In this tutorial, we will be creating a simple game using the Pygame library in Python. Pygame is a set of Python modules designed for writing video games. It provides functionality for creating 2D graphics, handling events, and playing sounds and music. By the end of this tutorial, you will have a basic understanding of how to create a game using Pygame and Python. Setting up the Development Environment Before we can start coding our game, we must set up our development environment. To do this, we will need to install Python and the Pygame library. If you already have Python installed on your machine, you can install Pygame by running the following command in your terminal: pip install pygame If you don't have Python installed, you can download the latest version from the official Python website. Once you have

How to write youtube channel description

Hey guys how are you all today in this post I am going to tell you that How to write youtube channel description . So if you want to know that how to write youtube channel description  then it is very easy there are simple tips for writing youtube channel description so now without any delay let's begin with this post:- watch the complete video here:-  https://youtu.be/CmZmozRmSFk   so guys if you want to write your channel description then you have to firstly learn that from where you have to edit your YouTube channel description. Firstly you have to open the YouTube Studio  website from there  you have to move to the customization tab. Now you have to go to the basic info option and from here youtube can edit your youtube channel description easily. How to write youtube channel description (Tips) In the first paragraph write a text which welcomes the viewer like the first paragraph of my post. In the second one write about your channel what you cover in that youtube channel etc.