A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 3 years ago
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
anonymous
 3 years ago
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

This Question is Open

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0sorry : 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
 3 years ago
Best ResponseYou've already chosen the best response.0I 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
 3 years ago
Best ResponseYou've already chosen the best response.0btw, what course are you taking?

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0I 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.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.