Dice Game Two Players Program in Python

Python
Python


Code:

import random
win1=0
win2=0
loose1=0
loose2=0
x=0
while(x<5):
    d1=random.randint(1,6)
    d2=random.randint(1,6)
    d3=random.randint(1,6)
    d4=random.randint(1,6)
    user1=d1+d2
    user2=d3+d4
    x=x+1
    if(user1==12 or user2==2):
        print("winner")
        win1=win1+1
    else:
        print("looser")
        loose1=loose1+1
    if(user2==12 or user2==2):
        print("winner")
        win2=win2+1
    else:
        print("looser")
        loose2=loose2+1
print("winnerOne",win1,"loose1 ",loose1)
print("winnerTwo",win2,"loose2",loose2)

Output:

looser
looser
looser
looser
looser
looser
looser
looser
looser
looser
winnerOne 0 loose1  5
winnerTwo 0 loose2 5
>>> 

Tags: python,dice,learn python,dice game,program,python (programming language),python tutorial,python game,dice roll,how to program using python,dice roller,rolling dice using python,how to make dice using python,how to use libraries in python,how to make dice rolling simulator using python,how to make a moving dice in pygame - python,programming,game,programming in python,roll the dice

Post a Comment

Previous Post Next Post