Skip to content

Commit ecea7c8

Browse files
committed
Add practice template, fix style
1 parent e640280 commit ecea7c8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Cashier Job
2+
# Write a function called calculate_total
3+
# that will take the number of pennies, nickels, dimes,
4+
# quarters, and discount rate (i.e. 15 for 15% discount).
5+
# Return the total amount of money after discount.
6+
#
7+
# Print what is returned by the function after it is run with 97 pennies,
8+
# 13 nickels, 18 dimes, 54 quarters, and 20% discount.
9+
# Print what is returned by the function after it is run with 32 pennies,
10+
# 19 nickels, 22 dimes, 71 quarters, and 51% discount.
11+
12+
# write code here
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
# Write a function that will take the number of pennies, nickels, dimes,
2-
# quarters, and discount(i.e. 15 for 15% discount). Return the total amount of
3-
# money after discount.
1+
# Cashier Job
2+
# Write a function called calculate_total
3+
# that will take the number of pennies, nickels, dimes,
4+
# quarters, and discount rate (i.e. 15 for 15% discount).
5+
# Return the total amount of money after discount.
46
#
57
# Print what is returned by the function after it is run with 97 pennies,
68
# 13 nickels, 18 dimes, 54 quarters, and 20% discount.
79
# Print what is returned by the function after it is run with 32 pennies,
810
# 19 nickels, 22 dimes, 71 quarters, and 51% discount.
911

1012

11-
def calc_total(penny, nickel, dime, quarter, discount):
13+
def calculate_total(penny, nickel, dime, quarter, discount):
1214
before_discount = (
1315
0.01 * penny + 0.05 * nickel + 0.1 * dime + 0.25 * quarter
1416
)
1517
discount_multiplier = 1 - discount * 0.01
1618

19+
# Round to 2 decimals since it is money
1720
return round(before_discount * discount_multiplier, 2)
1821

1922

20-
print(calc_total(97, 13, 18, 54, 20))
23+
print(calculate_total(97, 13, 18, 54, 20))
2124

22-
print(calc_total(32, 19, 22, 71, 51))
25+
print(calculate_total(32, 19, 22, 71, 51))

0 commit comments

Comments
 (0)