anonymous
  • anonymous
My code in Radiation expose 1 is: while final > init: print final result=f(final) print result print '------------------' resultfinal = resultfinal + result*ancho #resultadofinal=0.0 print resultadofinal final=final - 1 return resultfinal But not the same answer in the test: For (0,5,1) ---> Me =34.2839397259 instead of 39.10318784326239 Why ?? please help :P
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
sorry : The full code def f(x): import math return 10*math.e**(math.log(0.5)/5.27 * x) def area(inicio, final, ancho): print "de " +str(inicio ) +" a " +str(final) resultadofinal=0.0 while final > inicio: resultado=f(final) resultadofinal = resultadofinal + resultado*ancho final=final - 1 return resultadofinal print area(0, 5,1)
Lyrae
  • Lyrae
I think it should be something like this: def f(x): import math return 10*math.exp((math.log(0.5)/5.27) * x) def area(inicio, final, ancho): print "de " +str(inicio ) +" a " + str(final) resultadofinal = 0 while inicio < final: resultadofinal += f(inicio)*ancho inicio += ancho return resultadofinal print area(0, 5, 1)
Lyrae
  • Lyrae
btw, what course are you taking?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
I had the same issue at first. I did mine slightly different. In the body of the main function I defined the variable exposure to call the function f(start) and multiplied it by step. This returned the amount of radiation exposed times the length of time exposed and saved it to the variable. I then set up a while loop that ran while start is greater than stop minus step. Subtracting one keeps it from adding in the area after the stop point as well so that your answer isn't too large. For each loop the step was added to start (start += step) and then exposure was changed (exposure += f(start) * step) this calculates the next rectangle in the series. When start equals stop it returns the value of exposure. I think the problem with yours getting the wrong answer is similar to how mine was getting one that was too large before I subtracted step from my while loop. but since you are starting at the top stop point and working backwards yours is coming out too small. I hope this helps.

Looking for something else?

Not the answer you are looking for? Search for more explanations.