Game_01_Snake_Water_Gun_or_Rock_Paper_Scissor

 #snake water gun, or rock paper scissor


import random

def gameWin (comp ,you):
    if comp == you: # if two values are equal declear a tie
        return None
    #check for all possibilities when computer chose "s"
    elif comp == 's':
        if you == 'w':
            return
        elif you== 'g':
            return True
    #check for all possibilities when computer chose "w"
    elif comp == 'w':
        if you == 'g':
            return False
        elif you== 's':
            return True
    #check for all possibilities when computer chose "g"
    elif comp == 'g':
        if you == 's':
            return False
        elif you== 'w':
            return True


Game_Snake_Water_Gun_or_Rock_Paper_Scissor

# If you want to change "S" 'W' 'G' to 'R", P, S you can


print("comp Turn: Snake(s) Water(w) Gun(g)? ")
randNo = random.randint(1,3)
if randNo ==1 :
    comp = 's'
elif randNo ==2 :
    comp = 'w'
elif randNo ==3:
    comp = 'g'
#b= input("player 1 turn: Snake(s) Water(w) Gun(g)?") if you do not want to play with computer
# change variable comp to b, and remove that random variable,
# as random is introduced computer always chose random number
# you can put statement to print like "hey dear it's your turn " it looks impressive


you= input("your Turn: Snake(s) Water(w) Gun(g)?")

a= gameWin(comp, you)

print (f" Computer chose {comp}")
print (f" You chose {you}")

if a == None:
    print ("The game is tie!  ")
elif a:
    print(" Congratulations , You win..!")
else :
    print("You loose..!")

#b= input("player 1 turn: Snake(s) Water(w) Gun(g)?")


###### just enjoy it..... 

Comments

Popular posts from this blog

String Function

Conditional Expression