Advertisement
rfmonk

eg_1.py

Apr 7th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import math
  3. from math import radius
  4. from math import radians
  5.  
  6. e = math.exp(1.0)
  7. height = radius * math.sin(radians)
  8.  
  9.  
  10. # def area(radius):
  11. #    temp = math.pi * radius ** 2
  12. #    return temp
  13.  
  14.  
  15. # a more concise version
  16. def area(radius):
  17.     return math.pi * radius ** 2
  18.  
  19.  
  20. # temporary variables like temp make debugging easier
  21. #def absolute_value(x):
  22. #    if x < 0:
  23. #        return -x
  24. #    else:
  25. #        return x
  26.  
  27.  
  28. # Since these return statement are in an alternative
  29. # conditional, only one will be executed.
  30. # It is a good idea to ensure that every possible path
  31. # through the program hits a return statement.
  32. def absolute_value(x):
  33.     if x < 0:
  34.         return -x
  35.     if x > 0:
  36.         return x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement