-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandCricket.py
87 lines (80 loc) · 2.76 KB
/
handCricket.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import random
computerScore = 0
playerScore = 0
computer = 0
player = 1
playOn = ''
tossOptions = [0,1]
toss = random.choice(tossOptions)
inputToss = int(input('Enter your toss choice 0/1 :'))
if inputToss == toss:
print('you have win the toss.')
playOn = 'Player'
else:
print('You have lose the toss.')
playOn = 'computer'
while computer != player:
computer = random.randint(1,6)
player = int(input('Enter a number between 1-6 :'))
while player not in range(1,7):
print('Enter a number between 1 - 6')
player = int(input('Enter a number between 1-6 :'))
print('Computer said :',computer)
print('You said :',player)
if computer != player:
if playOn == 'computer':
computerScore += computer
else:
playerScore += player
if playOn == 'computer':
print('computer totals :',computerScore)
print('You need',computerScore,'to win.')
playOn = 'player'
else:
print('Your total score :',playerScore)
print('Computer needs',playerScore,'to win.')
playOn = 'computer'
computer = 0
player = 1
if computerScore > 0 and playerScore == 0:
while computer != player and playerScore < computerScore:
computer = random.randint(1,6)
player = int(input('Enter a number between 1-6 :'))
while player not in range(1,7):
print('Enter a number between 1 - 6')
player = int(input('Enter a number between 1-6 :'))
print('Computer said :',computer)
print('You said :',player)
if computer != player:
if playOn == 'computer':
computerScore += computer
else:
playerScore += player
if playOn == 'computer':
print('computer totals :',computerScore)
else:
print('Your total score :',playerScore)
elif playerScore > 0 and computerScore == 0:
while computer != player and computerScore < playerScore:
computer = random.randint(1,6)
player = int(input('Enter a number between 1-6 :'))
while player not in range(1,7):
print('Enter a number between 1 - 6')
player = int(input('Enter a number between 1-6 :'))
print('Computer said :',computer)
print('You said :',player)
if computer != player:
if playOn == 'computer':
computerScore += computer
else:
playerScore += player
if playOn == 'computer':
print('computer totals :',computerScore)
else:
print('Your total score :',playerScore)
if computerScore < playerScore:
print('You win.')
elif computerScore > playerScore:
print('Computer win.')
else:
print('Match draw.')