Page 1 of 1

Python: (Probability) Probability of an Event

Posted: Thu Oct 02, 2025 3:10 pm
by Jason

Code: Select all

print(f "What is the probability of unknowingly picking an orange in a basket containing an orange, apple, and pear?")

orange_outcome = 1

orange_outcome = O_F

O_F = apple_outcome = pear_outcome = 1

O_F + apple_outcome + pear_outcome = O_T 

# O_T is 3

float(OF)

float(OT)

float(P_E) = O_F/O_T

percent_P_E = P_E * 100

print(f "The probability of unknowingly picking an orange is {P_E} which is {percent_PE}%")

\(P(E) = \dfrac{O_{F}}{O_{T}}\)
Read: The probability of an event is outcomes favorable divided by outcomes total.
This is the building block of probability of which most other problems are built.
What is the probability of unknowingly picking an orange in a basket containing an orange, apple, and pear?
\(P(E) = \dfrac{O_{F}}{O_{T}}\)

\(P(orange) = \dfrac{orange}{orange, apple, pear} = \dfrac{1}{3} = 0.667 = 66.7 \%\)