6
6
flag = 0
7
7
points = 0
8
8
9
- # this function just Rrtuen Two random number in a tuple between 1 to 6
10
9
def drop_dice ():
11
10
one = random .randrange (1 ,7 )
12
11
two = random .randrange (1 ,7 )
13
12
print (f"Player Got { one } and { two } " )
14
13
print (f"Sum is { one + two } " )
15
14
return (one ,two )
16
15
17
- # this function drop Dice for first time
18
16
def first_drop ():
19
17
flag = 1
20
18
dice = drop_dice ()
21
- # unpack tuple
22
19
one ,two = dice
23
- # if sum of Dice is 7 or 11 Player win
24
20
if (one + two in [7 ,11 ]):
25
21
print ("Player Win in First Round!" )
26
22
sys .exit (0 )
27
- # else if sum of dice is 12 or 3 or 2 player lose
28
23
elif (one + two in [12 ,3 ,2 ]):
29
24
print ("Player Lose! in First Round!" )
30
25
sys .exit (1 )
31
- # else sum of dice is in [10,9,8,6,5,4] we set sum of dice to player point
32
26
elif (one + two in [10 ,9 ,8 ,6 ,5 ,4 ]):
33
27
points = one + two
34
28
print (f"POINTS is { points } " )
@@ -37,19 +31,14 @@ def first_drop():
37
31
38
32
39
33
def main ():
40
- # First round of game
41
34
if (flag == 0 ):
42
35
first_drop ()
43
- # if player can pass from first round now player should
44
- # drop dice until one of the condition is Come true
45
36
while True :
46
37
a = drop_dice ()
47
38
one , two = a
48
- # if player dice after first round come's 7 - player lose
49
39
if (one + two == 7 ):
50
40
print (f"Player Lose" )
51
41
sys .exit (1 )
52
- # if player dice after first round becomes equal to points - player wins
53
42
elif (one + two == points ):
54
43
print ("Player win! Points and Dice are same" )
55
44
sys .exit (0 )
0 commit comments