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.
importmath# Read input from STDINinput_line=input()# Split the input into a list of valuesvalues=input_line.split()# Convert the values to the appropriate data typesp=int(values[0])/100q=(1-p)n=int(values[1])defbinomial():resultOne=0resultTwo=0foriinrange(0,3):pdf=(math.factorial(n)/(math.factorial(i)*((math.factorial(n-i)))))*(p**i)*(q**(n-i))ifi<=2:resultOne=resultOne+pdfforiinrange(1,(n+1)):pdf=(math.factorial(n)/(math.factorial(i)*((math.factorial(n-i)))))*(p**i)*(q**(n-i))ifi>=2:resultTwo=resultTwo+pdfprint(round(resultOne,3))print(round(resultTwo,3))binomial()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 4: Binomial Distribution II
You are viewing a single comment's thread. Return to all comments →