def f(x): import math return 10*math.e**(math.log(0.5)/5.27 * x) def radiationExposure(start, stop, step): ''' Computes and returns the amount of radiation exposed to between the start and stop times. Calls the function f (defined for you in the grading script) to obtain the value of the function at any point. start: integer, the time at which exposure begins stop: integer, the time at which exposure ends step: float, the width of each rectangle. You can assume that the step size will always partition the space evenly. returns: float, the amount of radiation exposed to between start and stop times. ''' totalRad = 0.0 counter = start while counter < stop: totalRad+=f(counter)*step counter+=step else: return totalRad
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question