Created
June 6, 2015 02:59
-
-
Save kellegous/bb337b43d7612cf67941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import math | |
| def ex1(): | |
| return '%0.3f' % (4 * math.pi * math.pow(5, 3) / 3.0) | |
| def ex2(): | |
| return '$%0.2f' % (60*(24.95 * (1 - 0.4)) + 3.00 + 0.75*59) | |
| def ex3(): | |
| def time_to_mins(t): | |
| hr, mn = [int(x) for x in t.split(':')] | |
| return hr*60 + mn | |
| def mins_to_time(m): | |
| h = int(m / 60) | |
| return '%d:%d' % (h, m - h*60) | |
| def rate_in_mins(r): | |
| m, s = [int(x) for x in r.split(':')] | |
| return m + s/60.0 | |
| return mins_to_time(time_to_mins('6:52') + rate_in_mins('8:15')*2 + rate_in_mins('7:12')*3) | |
| print('Exercise 2.4') | |
| print(' 1: %s' % ex1()) | |
| print(' 2: %s' % ex2()) | |
| print(' 3: %s' % ex3()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment