Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # encoding: utf-8
- #
- # Copyright (c) 2010 Doug Hellmann. All rights reserved.
- #
- """Exponentiation
- """
- #end_pymotw_header
- import math
- for x, y in [
- # Typical uses
- (2, 3),
- (2.1, 3.2),
- # Always 1
- (1.0, 5),
- (2.0, 0),
- # Not-a-number
- (2, float('nan')),
- # Roots
- (9.0, 0.5),
- (27.0, 1.0/3),
- ]:
- print '{:5.1f} ** {:5.3f} = {:6.3f}'.format(x, y, math.pow(x, y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement