forked from davidezra00/Python-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockpaper.py
More file actions
70 lines (66 loc) · 1.1 KB
/
Rockpaper.py
File metadata and controls
70 lines (66 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import random
print('welcome to rock paper scissors')
scoreP=0
scoreC=0
comp=""
def computerchoice():
global comp
xv=random.randint(0,2)
if xv==0:
comp='r'
if xv==1:
comp='p'
if xv==2:
comp='s'
def scoring():
global scoreP
global scoreC
if choice=='r':
if comp=='p':
scoreC+=1
elif comp=='r':
pass
else :
scoreP+=1
if choice=='p':
if comp=='s':
scoreC+=1
elif comp=='p':
pass
else :
scoreP+=1
if choice=='s':
if comp=='r':
scoreC+=1
elif comp=='s':
pass
else :
scoreP+=1
def plays():
play=input('Play again? y/n : ')
if play=='y':
playing=True
elif play=='n':
playing=False
else :
pass
playing = True
while playing:
choice=input("\nChoose 'r' 'p' 's' 'break' : ")
if choice.lower()[0]=='b':
break
else:
computerchoice()
scoring()
print(f'Player score = {scoreP}')
print(f'Computer score = {scoreC}')
if scoreP==10:
playing=False
print('Player wins \n')
plays()
elif scoreC==10:
playing=False
print('Çomputer wins \n')
plays()
else:
pass