All problems
Boy-Girl Paradox Probability
Problem
A family has two children. If condition is the string at_least_one, you know at least one child is a boy and the probability both are boys is 1 / 3. If condition is older, you know the older child is a boy and the probability is 1 / 2.
Return 0.0 for any other condition.
Hint
List the four equally likely boy-girl orders and condition on the information given.
Test cases
case 1
in: ["at_least_one"]
expected: 0.3333333333333333
case 2
in: ["older"]
expected: 0.5
case 3
in: ["unknown"]
expected: 0
Starter codePython
def boy_girl_probability(condition):
# Your code here
pass3 test cases · run your code against them in the editor