18 lines
720 B
Python
18 lines
720 B
Python
def apply_discount(price, discount=0.05):
|
|
discounted_price = price * (1 - discount)
|
|
return discounted_price
|
|
|
|
def apply_tax(price, tax=0.07):
|
|
price_with_tax = price * (1 + tax)
|
|
return price_with_tax
|
|
|
|
def calculate_total(price, discount=0.05, tax=0.07):
|
|
discounted_price = apply_discount(price, discount)
|
|
discounted_price_with_tax = apply_tax(discounted_price, tax)
|
|
return discounted_price_with_tax
|
|
|
|
total_price_with_defaults = calculate_total(120)
|
|
total_price_with_custom_values = calculate_total(100, discount=0.10, tax=0.08)
|
|
|
|
print(f"Total cost with default discount and tax: ${total_price_with_defaults}")
|
|
print(f"Total cost with custom discount and tax: ${total_price_with_custom_values}") |