shahsaima432457 / python-for-project1

0 stars 0 forks source link

first game using python language #3

Open shahsaima432457 opened 6 months ago

shahsaima432457 commented 6 months ago

import random

snake water gun or Rock paper scissors

def gameWin(comp,you):

if two values are equal declare a tie!

if comp == you:
    return None
# check for all possibilities when computer chose s
elif comp == "s":
    if you =="w":
        return False
    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

print("computer turn:Snake(s) Water(w) or Gun(g)?") randNo = random.randint(1,3) if randNo ==1: comp ="s" elif randNo == 2: comp="w" elif randNo == 3: comp ="g"

you =input ("your trun: Snake(s) Water(w) or Gun(g)?") a=gameWin(comp,you)

print(f"computer chose{ comp}") print(f"you chose{ you}")

if a ==None: print("the game is a tie!") elif a: print("you win!") else: print ("you Lose")

shahsaima432457 commented 6 months ago

snake,water,gungame