Understanding Sequential Statements in Python
Execute the program by clicking the Run button at the bottom. You should get the following output:
State Tax: $81.25 Federal Tax: $350.00000000000006 Dependents: $62.5 Salary: $1250.0 Take-Home Pay: $756.25
Payroll.py code should look like this
salary = 1250.00 numDependents = 2 #input from user salary = float(input("input your salary amount: ")) numDependents = float(input("input your number of dependants: ")) # Calculate stateTax here. stateTax = salary*6.5/100 print("State Tax: $" + str(stateTax)) # Calculate federalTax here. federalTax = salary*28.0/100 print("Federal Tax: $" + str(federalTax)) # Calculate dependantDeduction here. dependentDeduction = (salary*2.5/100) * numDependents print("Dependents: $" + str(dependentDeduction)) # Calculate totalWithholding here. totalWithholding = stateTax + federalTax + dependentDeduction # Calculate takeHomePay here. takeHomePay = salary - totalWithholding print("Salary: $" + str(salary)) print("Take Home Pay: $" + str(salary - totalWithholding))
In this program, the variables named salary and numDependents are initialized with the values 1250.0 and 2. To make this program more flexible, modify it to accept interactive input for salary and numDependents.
(this information should be under "salary" and "numDependents") (lines 4-6) #input from user salary = float(input("input your salary amount: ")) numDependents = float(input("input your number of dependants: "))
Write the Python code needed to perform the following: > Calculate state withholding tax (stateTax) at 6.5 percent. > Calculate federal withholding tax (federalTax) at 28.0 percent. > Calculate dependent deductions (dependentDeduction) at 2.5 percent of the employee's salary for each dependent. > Calculate total withholding (totalWithholding) as stateTax + federalTax + dependentDeduction. > Calculate take-home pay (takeHomePay) as salary - totalWithholding
stateTax = salary*6.5/100 federalTax = salary*28.0/100 dependentDeduction = (salary*2.5/100) * numDependents totalWithholding = stateTax + federalTax + dependentDeduction takeHomePay = salary - totalWithholding