🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Discrete Probability: all 10 questions

Quiz: Discrete Probability · Question 7 of 10

What does this print? (code)

What does this print?

from fractions import Fraction as F
prior = {"A": F(1, 2), "B": F(1, 2)}
rate = {"A": F(1, 10), "B": F(3, 10)}
p = sum(prior[m] * rate[m] for m in prior)
print(prior["A"] * rate["A"] / p)
  1. A.1/10
  2. B.1/4
  3. C.1/2
  4. D.3/4
Answer & explanation

Correct answer: 1/4

P(D) = 1/20 + 3/20 = 1/5, so P(A | D) = (1/20) / (1/5) = 1/4.

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 →