from random import randint
gold = 0
silver = 1
boxes = ( [gold, gold], [gold, silver], [silver, silver] )
total = 0
num_next_ball_gold = 0
for i in range(1000000):
box_num = randint(0, 2)
box = boxes[box_num]
ball_choice = randint(0, 1)
ball = box[ball_choice]
if ball_choice == gold:
other_ball_choice = (ball_choice + 1) % 2
other_ball = box[other_ball_choice]
total += 1
num_next_ball_gold += (0 if other_ball != gold else 1)
print(num_next_ball_gold/total)
python prog/
ballproblem.py0.3333692886049754