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.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportmathdefget_function(x):mu=20sig=2gaussian_func=(1/(sig*math.sqrt(2*math.pi)))*math.exp(-((x-mu)**2)/(2*sig**2))returngaussian_funcstart_value=12end_value=28step=0.0001x=[start_value+i*stepforiinrange(int((end_value-start_value)/step)+1)]y=0y1=0y2=0foriinrange(len(x)):y+=get_function(x[i])*stepifx[i]<19.5:y1+=get_function(x[i])*stepif20<x[i]<22:y2+=get_function(x[i])*stepresult1=int((y1/y)*1000)/1000result2=int((y2/y)*1000)/1000print(str(result1))print(str(result2))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 4: Normal Distribution #2
You are viewing a single comment's thread. Return to all comments →
Here is my answer: