Skip to content

Commit

Permalink
Create RockPaperScissor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirtiahuja authored Oct 10, 2020
1 parent 5869cab commit 50dd03a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions RockPaperScissor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import random#Rock paper scissor
def gameWin(comp, you):
    # declare a tie!
    if comp == you:
        return None    # when computer chose rock
    elif comp == 'r':
        if you=='s':
            return False
        elif you=='p':
            return True

    # when computer chose paper
    elif comp == 'p':
        if you=='r':
            return False
        elif you=='s':
            return True

    # when computer chose scissor
    elif comp == 's':
        if you=='p':
            return False
        elif you=='r':
            return Trueprint("Comp Turn: Rock(r) Paper(p) or scissor(s)?")
randNo = random.randint(1, 3)
if randNo == 1:
    comp = 'r'
elif randNo == 2:
    comp = 'p'
elif randNo == 3:
    comp = 's'you = input("Your Turn: Rock(r) Paper(p) or scissor(s)?")
a = gameWin(comp, you)
print ("\n")
print(f"1] Computer chose:- {comp}")
print(f"2] You chose:- {you} ")if a == None:
    print("==> The game is a tie! ")
elif a:
    print("==> You Win! 🤩")
else:
    print("==> You Lose! ☹️")

0 comments on commit 50dd03a

Please sign in to comment.