You are viewing a single comment's thread. Return to all comments →
from itertools import product from fractions import Fraction
P = list(product([1, 2, 3, 4, 5, 6], repeat=2))
N = sum(1 for x in P if sum(x) <= 9)
print(Fraction(N, len(P)))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability
You are viewing a single comment's thread. Return to all comments →
from itertools import product from fractions import Fraction
P = list(product([1, 2, 3, 4, 5, 6], repeat=2))
N = sum(1 for x in P if sum(x) <= 9)
print(Fraction(N, len(P)))