The net chargeable income is salaries minus allowances and deductions. For simplicity,…
- User
The net chargeable income is salaries minus allowances and deductions. For simplicity, assume the only deductible is the mandatory contribution to MPF, and the only allowance is the single/married person allowance.1 A single person will receive an allowance of HKD 132,000, and a married person will receive HKD 264,000. Write a Python program to calculate the income tax.
- Ask the user to enter the salary, marriage status, and mandatory contributions to MPF.
- Display the tax due. Round it to the nearest dollar amount. If the net chargeable income is negative, display 0 for the tax due. The program should be capable of the following. Each screenshot corresponds to running the program once. Follow the same submission requirement (.py file and screenshot) as before.
- Assistant
Below is a Python script that you can use to calculate the income tax based on the salary, marriage status, and mandatory MPF contributions. You can save this as a .py file (e.g.,
tax_calculator.py) and run it to enter the required details to calculate the tax.def calculate_tax_due(salary, married, mpf_contribution): single_allowance = 132000 married_allowance = 264000 allowance = married_allowance if married else single_allowance net_income = salary - mpf_contribution - allowance # Tax brackets and rates in Hong Kong tax_brackets = [50000, 50000, 50000, 50000] # Each additional bracket of taxable income tax_rates = [0.02, 0.06, 0.1, 0.14] # Corresponding tax rates for each bracket remaining_income = net_income tax_due = 0 # Calculate the tax for bracket, rate in zip(tax_brackets, tax_rates): if remaining_income > bracket: tax_due += bracket * rate remaining_income -= bracket else: tax_due += remaining_income * rate break # Additional tax for the remaining income at 17% if applicable if remaining_income > 0: tax_due += remaining_income * 0.17 # Round the tax to the nearest dollar amount tax_due = round(tax_due) # If the net chargeable income is negative, tax due is 0 if net_income < 0: tax_due = 0 return tax_due # User inputs salary = float(input('Please enter your annual salary: ')) marriage_status = input('Are you married? (yes/no): ') mpf_contribution = float(input('Please enter your mandatory contribution to MPF: ')) # Check if married is_married = True if marriage_status.lower() == 'yes' else False # Calculate the tax tax = calculate_tax_due(salary, is_married, mpf_contribution) # Output the result print(f'The tax due is: HKD {tax}') - User
Feather Friends, Incorporated, distributes a high-quality wooden birdhouse that sells for 20.00 per unit, and fixed expenses total $160,000 per year. Its operating results for last year were as follows:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.