Skip to content

Commit f0e071d

Browse files
authored
Update Roll-dice.py
1 parent 7b49f73 commit f0e071d

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

Roll-Dice-Game/Roll-dice.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,23 @@
66
flag = 0
77
points = 0
88

9-
# this function just Rrtuen Two random number in a tuple between 1 to 6
109
def drop_dice():
1110
one = random.randrange(1,7)
1211
two = random.randrange(1,7)
1312
print(f"Player Got {one} and {two}")
1413
print(f"Sum is {one + two}")
1514
return (one,two)
1615

17-
# this function drop Dice for first time
1816
def first_drop():
1917
flag = 1
2018
dice = drop_dice()
21-
# unpack tuple
2219
one,two = dice
23-
# if sum of Dice is 7 or 11 Player win
2420
if (one + two in [7,11]):
2521
print("Player Win in First Round!")
2622
sys.exit(0)
27-
# else if sum of dice is 12 or 3 or 2 player lose
2823
elif(one+two in [12,3,2]):
2924
print("Player Lose! in First Round!")
3025
sys.exit(1)
31-
# else sum of dice is in [10,9,8,6,5,4] we set sum of dice to player point
3226
elif(one+two in [10,9,8,6,5,4]):
3327
points = one+two
3428
print(f"POINTS is {points}")
@@ -37,19 +31,14 @@ def first_drop():
3731

3832

3933
def main():
40-
# First round of game
4134
if (flag == 0):
4235
first_drop()
43-
# if player can pass from first round now player should
44-
# drop dice until one of the condition is Come true
4536
while True:
4637
a = drop_dice()
4738
one , two = a
48-
# if player dice after first round come's 7 - player lose
4939
if (one + two == 7):
5040
print(f"Player Lose")
5141
sys.exit(1)
52-
# if player dice after first round becomes equal to points - player wins
5342
elif (one + two == points):
5443
print("Player win! Points and Dice are same")
5544
sys.exit(0)

0 commit comments

Comments
 (0)