I am trying to write a python program to find the probability of a scenario to occur given the probability of other scenarios. Below is the situation:
A deck of cards has white and black cards. I draw 2 cards randomly without replacement.
Given Probability 1: Probability of selecting a white and then a black card is x. Given Probability 2: Probability of selecting a white card in the first draw is y.
I need to find the probability of drawing a black card, given that the first card drawn was white.
Mathematically, this is what I could figure out:
#Probability of selecting a white and then a black card is x (W is white, B is black) x = (W/ ( W + B) ) * (B /( W + B - 1)
#The probability of selecting a white card in the first draw is y y = W/ ( W + B)
x = y* B/(W+B - 1)
B/(W+B - 1) = x/y
So ultimately, x/y would be the solution to the above problem.
My Question: When trying to code this solution in python, do I need to do the initial calculation mathematically and write the below code or can I do the above calculation which i did mathematically in python to avoid doing the manual work?
x=float(input())
y=float(input())
result=float(x/y)
print(result)