-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
27 lines (21 loc) · 845 Bytes
/
Copy pathutil.py
File metadata and controls
27 lines (21 loc) · 845 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
def safe_int_input(prompt):
while True:
try:
value = int(input(prompt))
if value < 0:
print("Please enter a positive number.")
continue
return value
except ValueError:
print("Invalid input. Please enter a number.")
def process_coins():
quarters = safe_int_input("How many quarters? ")
dimes = safe_int_input("How many dimes? ")
nickels = safe_int_input("How many nickels? ")
pennies = safe_int_input("How many pennies? ")
total = ((quarters * 0.25) + (dimes * 0.10) + (nickels * 0.05) + (pennies * 0.01))
return round(total,2) # print upto 2 decimal places
def print_report(resource, profit):
for item, value in resource.items():
print( f" {item.capitalize()}: {value} ")
print(f" Money: ${profit}")