Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. #
  4. # Copyright (c) 2010 Doug Hellmann. All rights reserved.
  5. #
  6. """Exponentiation
  7. """
  8. #end_pymotw_header
  9.  
  10. import math
  11.  
  12. for x, y in [
  13. # Typical uses
  14. (2, 3),
  15. (2.1, 3.2),
  16.  
  17. # Always 1
  18. (1.0, 5),
  19. (2.0, 0),
  20.  
  21. # Not-a-number
  22. (2, float('nan')),
  23.  
  24. # Roots
  25. (9.0, 0.5),
  26. (27.0, 1.0/3),
  27. ]:
  28. print '{:5.1f} ** {:5.3f} = {:6.3f}'.format(x, y, math.pow(x, y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement