0% found this document useful (0 votes)
19 views

Python

The document describes a rock-paper-scissors game between a user and computer where the user and computer randomly select rock, paper, or scissors each round and points are tracked for each win until the user enters 'q' to quit and see the final scores.

Uploaded by

akash yadav
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Python

The document describes a rock-paper-scissors game between a user and computer where the user and computer randomly select rock, paper, or scissors each round and points are tracked for each win until the user enters 'q' to quit and see the final scores.

Uploaded by

akash yadav
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import random

r= ["r","p","s"]

d={'r':"rock",'p':"paper",'s':"scissors",'q':"quit"}

i=0

a=0

while True:

l=input("enter you choice:")

print("user has choosen",d[l])

x=random.choice(r)

print("computers has choosen",d[x])

if l=='q':

print("user's score",a)

print("computer's score",i)

if i>a:

print("computer won with ",i,"points")

elif i==a:

print("match drawn")

else :

print("user won with",a,"points")

exit()
elif l==x :

print("match drawn")

elif l=="rock" and x=="paper" or l=="scissors" and x=="rock" or x=="scissors"


and l=="paper":

print ("computer wins")

i=i+1

else:

print("you won")

a=a+1

You might also like