All problems

Students Studying Two Languages

mediumPythonProbabilityConditional Probability

The registrar at Whetcode College is building next term's timetable, one year group at a time. For each year group she has four counts: how many students are in it, how many are enrolled in French, how many in Spanish, and how many names appear on both lists. Students on both lists are already counted inside the French figure and inside the Spanish figure rather than being extra students.

The timetabler's question is narrower than it first sounds. She is not asking how common Spanish is across the year — she is standing in the French class, looking at the students in front of her, and asking what share of those also need a Spanish slot, because that is what decides whether the two classes can be scheduled in the same period.

Task: Print P(Spanish | French) — the probability that a randomly chosen student studies Spanish given that they study French — rounded to 2 decimals.

Input

Four lines, each holding one whole number, in this order: the size of the year group, the number enrolled in French, the number enrolled in Spanish, and the number enrolled in both. At least one student takes French.

Output

One line holding the conditional probability, rounded to 2 decimals and printed the way Python prints a float — 0.6, never 0.60.

Example:

Input:
100
40
30
10

Output:
0.25

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…