-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange.py
More file actions
27 lines (22 loc) · 686 Bytes
/
Copy pathchange.py
File metadata and controls
27 lines (22 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import math
def change(money):
coins = { 'half_dollar': 0, 'quarter': 0, 'dime': 0, 'nickel': 0, 'penny': 0 }
if (money <= 0):
return coins
if (money >= .5):
coins['half_dollar'] = math.trunc(money/.5)
money = money % .5
if (money >= .25):
coins['quarter'] = math.trunc(money/.25)
money = money % .25
if (money >= .1):
coins['dime'] = math.trunc(money/.1)
money = money % .1
if (money >= .05):
coins['nickel'] = math.trunc(money/.05)
money = money % .05
if (money >= .01):
coins['penny'] = math.trunc(round((money/.01),2))
return coins
money = 2.30
print(change(money))