Skip to content

Commit de3c56a

Browse files
authored
Merge branch 'master' into Citrus716-patch-5
2 parents b7b1baa + d5a2f2f commit de3c56a

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
13+
def calculate_total(penny, nickel, dime, quarter, discount):
14+
before_discount = (
15+
0.01 * penny + 0.05 * nickel + 0.1 * dime + 0.25 * quarter
16+
)
17+
discount_multiplier = 1 - discount * 0.01
18+
19+
# Round to 2 decimals since it is money
20+
return round(before_discount * discount_multiplier, 2)
21+
22+
23+
print(calculate_total(97, 13, 18, 54, 20))
24+
25+
print(calculate_total(32, 19, 22, 71, 51))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Number Mystery 1
2+
# Write a function called num_mystery that takes in 3 integers.
3+
# The function should calculate the sum of the 3 integers and
4+
# the difference between the largest integer and the smallest integer.
5+
# The function should return the product of these two integers you calculated.
6+
#
7+
# Hint: You may find it useful to use the max() and min() functions.
8+
#
9+
# Use the num_mystery function on 1, 2, 3 and print the result.
10+
# Use the num_mystery function on 5, 13, 7 and print the result.
11+
12+
13+
def num_mystery(first_int, second_int, third_int):
14+
# calculate the sum of the 3 numbers
15+
sum_of_three = first_int + second_int + third_int
16+
17+
# calculate the difference between the max and min
18+
largest = max(first_int, second_int, third_int)
19+
smallest = min(first_int, second_int, third_int)
20+
difference = largest - smallest
21+
22+
# return the product
23+
return sum_of_three * difference
24+
25+
26+
print(num_mystery(1, 2, 3)) # prints 12
27+
print(num_mystery(5, 13, 7)) # prints 200

0 commit comments

Comments
 (0)