-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradiationExposure.py
More file actions
27 lines (24 loc) · 872 Bytes
/
radiationExposure.py
File metadata and controls
27 lines (24 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def f(x):
import math
return 400*math.e**(math.log(0.5)/3.66 * 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.
'''
# FILL IN YOUR CODE HERE...
x_now=start
area=0
while 1:
if x_now>=stop:
return area
area+=f(x_now)*step
x_now+=step