Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Python/task/Nikunj/OUTPUT_1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python/task/Nikunj/OUTPUT_2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Python/task/Nikunj/Python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#Dice Roll game
import random as r
while True:
try:
goal=int(input('Enter the GOAL: '))
if goal<1: 0/0
score_1=score_2=0
turn=1

while True:
print('\nTurn:',turn)
turn+=1
x=input('Player_1 press "ENTER" to roll the dice. ')
a=r.randint(1,6)
print('\tYou got',a)
if score_1+a<=goal:
score_1+=a
print('\tSCORE =',score_1)

x=input('Player_2 press "ENTER" to roll the dice. ')
b=r.randint(1,6)
print('\tYou got',b)
if score_2+b<=goal:
score_2+=b
print('\tSCORE =',score_2)

if score_1==goal and score_2!=goal:
print('\nPlayer_1 is the winner!!!')
break
elif score_2==goal and score_1!=goal:
print('\nPlayer_2 is the winner!!!')
break
elif score_1==goal and score_2==goal:
print("\nIt's a tie!!!")
break

except:
print('Invalid goal, try again.')
choice=input('\nPress "q" or "Q" to quit the game: ')
if choice in ('q','Q'):
break
print('\nTHANK YOU for playing this game!!!')