Dice Game Program in Python

Python
Python


Code:

import random
win=0
loose=0
x=0
while(x<10):
    d1=random.randint(1,6)
    d2=random.randint(1,6)
    d3=random.randint(1,6)
    d4=random.randint(1,6)
    sum=d1+d2+d3+d4
    if(sum==24 or sum==4):
        print("winner")
        win=win+1
        x=x+1
    else:
        print("looser")
        loose=loose+1
        x=x+1
print("win",win,"loose",loose)

Output:

looser
looser
looser
looser
looser
looser
looser
looser
looser
looser
win 0 loose 10
>>> 

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