Answer:
- TAX_RATE = 0.20
- STANDARD_DEDUCTION = 10000.0
- DEPENDENT_DEDUCTION = 3000.0
-
- # Request the inputs
- grossIncome = float(input("Enter the gross income: "))
- numDependents = int(input("Enter the number of dependents: "))
-
- # Compute the income tax
- taxableIncome = grossIncome - STANDARD_DEDUCTION - \
- DEPENDENT_DEDUCTION * numDependents
- incomeTax = taxableIncome * TAX_RATE
-
- # Display the income tax
- print("The income tax is $" + str(round(incomeTax,2)))
Step-by-step explanation:
We can use round function to enable the program to output number with two digits of precision.
The round function will take two inputs, which is the value intended to be rounded and the number of digits of precision. If we set 2 as second input, the round function will round the incomeTax to two decimal places. The round function has to be enclosed within the str function so that the rounded value will be converted to a string and joined with the another string to display the complete a sentence of income tax info.