Closure - App

Run Settings
LanguagePython
Language Version
Run Command
def sales_tax_calculator(tax_rate_percent): """Returns a closure that calculates total coast including""" def calculate(amount): return amount * (1 + tax_rate_percent / 100) return calculate # Example usage: calculate_ny_tax = sales_tax_calculator(8.875) # NY tax rate : calculate_ca_tax = sales_tax_calculator(7.25) # Calculate totals ny_total = calculate_ny_tax(100.0) ca_total = calculate_ca_tax(100.0) print(f"NY Total (${100} + tax): ${ny_total:.2f}") print(f"CA Total (${100} + tax): ${ca_total:.2f}") # line 1 to 5 is only for register variables and the calculation is in line 12-13
Editor Settings
Theme
Key bindings
Full width
Lines