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

The Professional HTML Cheatsheet For beginners in 2024 for free

The Professional HTML Cheatsheet For beginners in 2024 for free Hello guys,  You will be glad to know that I am going to start a cheatsheet series for you all. In this series I am going to give you cheat sheets of all the programming languages. If you want to get all of these cheat sheets for free then you can follow this blog and visit my youtube channel if you like the video content. This is the link to my youtube channel :- https://www.youtube.com/channel/UCmbrOCauavTcwIJeXYo4pjQ This is the link to my instagram :- https://instagram.com/gautam9465580 Father of all the links (Link to all of my social media platforms) :- https://code-and-man.blogspot.com/p/my-link-tree.html Now got all the information which I want to give you before the post so now let’s get started with the post:- In today’s post I am going to give you the first cheatsheet which is of HTML so let’s begin:- Boilerplate of HTML The Boilerplate code is the common code which is used in almost all of the web pages c...

Arrays and conversion in Javascript || javascript complete course || #7 (sourcecode)

hey guys how are you all today in this post I am going to give you the source code of my video called arrays and  conversion in JavaScript so let's begin:- // ARRAYS in javascript console . log (" This is arrays in js ") var arr1 = [ 32 , 34 , 23 , 23 , 234 ," this ", {     name:" Gautam ",     class : " 8th ",     rollno: 6 } ] console . log ( arr1 ) console . log ( arr1 [ 5 ]) console . log ( arr1 .length) console . log ( arr1 . concat (' main ')); console . log ( arr1 ); // // ---------------------------------------------------- // CONVERSION IN JAVASCRIPT // Converting in to strings var num1 = 45 ; console . log ( num1 ); var str1 = String ( num1 ); console . log ( str1 ); console . log ( typeof str1 ); console . log ( typeof num1 ); var number1 = 33453434 ; console . log ( number1 , typeof number1 ); var string1 = number1 . toString (); console . log ( string1 , typeof string1 ); // ----------------------------...

types of operators in javascript || javascript course || codeandman (sourcecode)

hey guys how are you all today in this post I am going to give you the source code of my video called types of operators in javascript. so let's begin : here's the complete source code and the video:- // ------------------------------------------------------------------------------------ // COMPARISON OPERATORS IN JAVASCRIPT console . log (" COMPARISON OPERATORS IN JAVASCRIPT ") console . log ( 32 == 32 ) // checking if 32 is equal to 32 console . log ( 32 != 32 ) // checking if 32 is not equal to 32 console . log ( 32 >= 31 ) // checking if 32 is greater or equal to 31 console . log ( 32 < 33 ) console . log ( 32 > 30 ) console . log ( 32 <= 09 ) // ASSIGNMENT OPERATORS console . log (" --------------------------------------- ") console . log (" Assignment operators in javascript ") var d = 34 ; var e = 3 ; var a = 10 ; console . log ( d ) console . log ( d += 1 ) console . log ( d -= 3 ) console . log ( e *= 2 ) console . log...