The Approach
This is a classic application of Bayes' Theorem. We are asked to find the conditional probability P(A | Defective).
We know:
• P(A) = 0.60, P(Defective | A) = 0.02
• P(B) = 0.40, P(Defective | B) = 0.01
We calculate the total probability of a defective item using the law of total probability, and then divide the joint probability of (A and Defective) by this total.
Python Solution
While this can be solved on paper, writing a simulation ensures we handle edge cases correctly and allows us to scale if the number of machines increases.