Problem 3: Conditional Probability Calculator
Easypython
Learn the Concept: Probability BasicsProblem Description
Write a Python program that takes the number of students studying Math, the number studying Science, and the number studying both, and calculates P(Science | Math) using the conditional probability formula.
Input
Three integers: total students, number studying Math, and number studying both Math and Science.
Output
The calculated conditional probability P(Science | Math).
Constraints
- Number studying Math must be greater than 0.
- Number studying both must not exceed the number studying Math.
Example Input
texttotal_students = 100, math_students = 40, both = 10
Example Output
textP(Science | Math): 0.25
Concepts Covered
Conditional probability formula, basic arithmetic, function design.
Related Problems
- Problem 1: Coin Flip SimulatorEasy · pythonSolve Problem
- Problem 2: Dice Roll Event ProbabilityEasy · pythonSolve Problem
- Problem 4: Card Draw Probability (Without Replacement)Easy · pythonSolve Problem