0% found this document useful (0 votes)
324 views3 pages

Project 1-Stone Paper Scissors

This document contains code for a rock paper scissors game. The code imports the random module and defines a gamewin function that takes the computer and player's choice as parameters and returns True, False or None to determine if the player wins, loses or ties. It then prompts the computer and player for a choice, runs the choices through the gamewin function and prints the result.

Uploaded by

Hrudaya Gadkari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
324 views3 pages

Project 1-Stone Paper Scissors

This document contains code for a rock paper scissors game. The code imports the random module and defines a gamewin function that takes the computer and player's choice as parameters and returns True, False or None to determine if the player wins, loses or ties. It then prompts the computer and player for a choice, runs the choices through the gamewin function and prints the result.

Uploaded by

Hrudaya Gadkari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Project 1-

Project code:-

import random

# Stone paper scissor Rock Paper Scissors

def gamewin(comp, you):

if comp == you:

return None

elif comp == 't':

if you=='p':

return False

elif you=='s':

return True

elif comp == 'p':

if you=='s':

return False

elif you=='t':

return True

elif comp == 's':


if you=='p':

return False

elif you=='t':

return True

print("Comp Turn: Stone(t) paper(p) or scissor(s)?")

randNo = random.randint(1, 3)

if randNo == 1:

comp = 't'

elif randNo == 2:

comp = 'p'

elif randNo == 3:

comp = 's'

you = input("Your Turn: stone(t) paper(p) or scissor(s)?")

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!")

Output:-

Comp Turn: Stone(t) paper(p) or scissor(s)?

Your Turn: stone(t) paper(p) or scissor(s)?t

Computer chose p

You chose t

You Win!

You might also like