- Hello Friends This is a Python Code of Dice Game
- Note: This Code For Only Two Players
- Copy This Code And Paste Your Python Compiler Or Computer And Run.
Dice Game program:
#Dicegame python program created by CodexRitik
import random
def dice_roll():
diceroll = random.randint(1, 6)
return diceroll
def main():
f = input("player1 name:")
s = input("player2 name:")
player1 =0
player2 =0
player1wins=0
player2wins=0
for rounds in range(1,11):
print("Round"+str(rounds))
player1 = dice_roll()
player2 = dice_roll()
print(f,"Roll:"+str(player1))
print(s,"Roll:"+str(player2))
if(player1==player2):
print("Game Draw!\n")
elif player1 > player2:
player1wins = player1wins+1
print(f,"Wins:\n")
else:
player2wins = player2wins+1
print(s,"Wins:\n")
if player1wins == player2wins:
print("Game Draw!")
print(f,"Wins match:"+str(player1wins))
print(s,"Wins match:"+str(player2wins))
elif player1wins > player2wins:
print(f,"Wins - Rounds Won:"+str(player1wins))
else:
print(s,"Wins - Rounds Won:"+str(player2wins))
main()
Dice Game|| In Python || CodexRitik
Reviewed by CodexRitik
on
March 31, 2020
Rating:
This information is so useful and informative which you have shared here. It is beneficial for beginners to develop their knowledge. It is very gainful information. Thanks for share it. dnd dice
ReplyDeleteThanks Man for Your Valuable Feedback!
Delete