Use function to write a program the prompts the user for their income and calculates the tax payable based on the Tax Office。Income Tax on this income0 – $18200 Nil18201– 45000 19 cents for each 1𝑜?
def calculate_tax(income): if income <= 18200: tax = 0 elif 18201 <= income <= 45000: tax = (income - 18200) * 0.19 elif 45001 <= income <= 120000: tax = 5092 + (income - 45000) * 0.325 elif 120001 <= income <= 180000: tax = 29467 + (income - 120000) * 0.37 else: tax = 51667 + (income - 180000) * 0.45 return tax
income = float(input("Enter your income: ")) tax_payable = calculate_tax(income) print("Your tax payable is: $", round(tax_payable, 2)
原文地址: http://www.cveoy.top/t/topic/hsxf 著作权归作者所有。请勿转载和采集!