← Quiz: Discrete Probability: all 10 questions
Quiz: Discrete Probability · Question 4 of 10
What does this print? (code)
What does this print?
from fractions import Fraction
from itertools import product
S = list(product(range(1, 7), repeat=2))
F = [o for o in S if o[0] == 6]
print(Fraction(sum(1 for o in F if sum(o) >= 10), len(F)))
- A.1/6
- B.1/12
- C.1/2
- D.1/3
Answer & explanation
Correct answer: 1/2
Given the first die is 6, the sum is at least 10 when the second die is 4, 5 or 6: 3 out of 6.
Can you get the rest right without peeking?
Take the timed Quiz: Discrete Probability quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →