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=30sig=4gaussian_func=(1/(sig*math.sqrt(2*math.pi)))*math.exp(-((x-mu)**2)/(2*sig**2))returngaussian_funcstart_value=10end_value=50step=0.0001x=[start_value+i*stepforiinrange(int((end_value-start_value)/step)+1)]y0=0y1=0y2=0y3=0foriinrange(len(x)):y0+=get_function(x[i])*stepifx[i]<40:y1+=get_function(x[i])*stepifx[i]>21:y2+=get_function(x[i])*stepif30<x[i]<35:y3+=get_function(x[i])*stepresult1=int((y1/y0)*1000)/1000result2=int((y2/y0)*1000)/1000result3=int((y3/y0)*1000)/1000print(str(result1))print(str(result2))print(str(result3))
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 #1
You are viewing a single comment's thread. Return to all comments →
Here is my answer: