Search This Blog

Probability and Statistics - 7 Problem statement HackerRank handsOn Fresco Play Solution

  • On new Year's Eve, the probability of a person having a car accident 0.09. The probability of a person driving while intoxicated is 0.32 and the probability of a person having a car accident while intoxicated is .15.
  • What is the probability of a person driving while intoxicated or having a car accident?
  • Probabilities:
  1. P(accident)=0.09
  2. P(intoxicated)=0.32
  3. P(accident and intoxicated)=0.15
Note:
  1. Return the probability in decimal rounded off to 2 decimal places
  2. Hint: Use Addition rule and Non-Mutually Exclusive
Function Description

Function Name: accident()
  1. Output:
    • ans: Float  - Denoting probability of a person driving while intoxicated or having a car accident?
Answer:

from scipy import stats

def accident():
    '''
    output: ans : Float
    '''
    #Write your code here
    #Assign the probability value to the variable ans. Round off to 2 decimal places
    accident = 0.09
    intoxicated = 0.32
    ai = 0.15
    
    prob =(accident+intoxicated)-ai
    
    ans=round(prob,2)
    
    return ans

if __name__=='__main__':


Click on the tested image:



No comments:

Post a Comment

If you have any doubts, Please let us know.