خرید بک لینک

Vote count: -2

I'm trying to simulate game of craps with python. I can't find a mistake in my code, but the results printed are for sure wrong because number of loses and wins don't sum up to number of plays, also number of wins is suspicously low.

from random import randint

def rolladice():
retu randint(1,6)

n=int(input("How many games do you want to simulate?"))


loses=0
wins=0

for i in range(n):
    sumOfRolls= rolladice() + rolladice()
    if(sumOfRolls== 2 or sumOfRolls == 3 or sumOfRolls== 12):
        loses += 1

    elif(sumOfRolls== 7 or sumOfRolls ==11):
        wins=+1

    else:
        while True:
            additionalRoll= rolladice()+ rolladice()
            if(additionalRoll== 7):
                loses+=1
                break
            elif(additionalRoll== sumOfRolls):
                wins+=1
                break

print("You have won {0} and lost {1} games. The eestimated probability od wiing is: {2}".format(wins, loses, wins/n))

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 24 خرداد 1395 ساعت: 0:24

صفحه بندی