We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Probabilitiesurn_x={'R':4/7,'B':3/7}urn_y={'R':5/9,'B':4/9}urn_z={'R':1/2,'B':1/2}# Scenariosscenarios=[['R','B','R'],#RfromX,BfromY,RfromZ['B','R','R'],#BfromX,RfromY,RfromZ['R','R','B']#RfromX,RfromY,BfromZ]# Calculate probabilities for each scenariototal_probability=0forscenarioinscenarios:probability=1foriinrange(3):ifi==0:probability*=urn_x[scenario[i]]elifi==1:probability*=urn_y[scenario[i]]else:probability*=urn_z[scenario[i]]total_probability+=probabilityprint("The probability of drawing 2 red balls and 1 black ball is:",total_probability)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Compound Event Probability
You are viewing a single comment's thread. Return to all comments →