Advertisement
andruhovski

radiationExposure.py

Mar 3rd, 2013
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. def radiationExposure(start, stop, step):
  2.     '''
  3.    Computes and returns the amount of radiation exposed
  4.    to between the start and stop times. Calls the
  5.    function f (defined for you in the grading script)
  6.    to obtain the value of the function at any point.
  7.  
  8.    start: integer, the time at which exposure begins
  9.    stop: integer, the time at which exposure ends
  10.    step: float, the width of each rectangle. You can assume that
  11.      the step size will always partition the space evenly.
  12.  
  13.    returns: float, the amount of radiation exposed to
  14.      between start and stop times.
  15.    '''
  16.     totalExposure = 0
  17.     x=start
  18.     while x<stop:
  19.         totalExposure += (f(x)*step)
  20.         x+=step
  21.     return totalExposure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement