172k views
5 votes
Some variables have been assigned for you and the output statements have been written. Read the starting code carefully before you proceed to the next step. 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 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 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.

1 Answer

3 votes

Answer:

salary = 1250

numofDependents = 2

stateTax = (6.5/100)*salary

federalTax = (28/100)*salary

dependentDeduction = ((2.5/100)*salary)*(numofDependents)

totalWithHolding = stateTax+federalTax+dependentDeduction

takeHomePay = salary - totalWithHolding

print('State Tax: {}'.format(stateTax))

print('Federal Tax: {}'.format(federalTax))

print('Dependents: {}'.format(dependentDeduction))

print('Salary: {}'.format(salary))

print('Take Home: {}'.format(takeHomePay))

MODIFIED TO ACCEPT FOR SALARY AND NUMBER OF DEPENDENTS

salary = float(input("Please enter your salary: "))

numofDependents = int(input("How many dependents do you have "))

stateTax = (6.5/100)*salary

federalTax = (28/100)*salary

dependentDeduction = ((2.5/100)*salary)*(numofDependents)

totalWithHolding = stateTax+federalTax+dependentDeduction

takeHomePay = salary - totalWithHolding

print('State Tax: {}'.format(stateTax))

print('Federal Tax: {}'.format(federalTax))

print('Dependents: {}'.format(dependentDeduction))

print('Salary: {}'.format(salary))

print('Take Home: {}'.format(takeHomePay))

Step-by-step explanation:

See the attached screen shot for the input and program output

The input Statement in python is used to receive and store the values for salary and number of dependents

Some variables have been assigned for you and the output statements have been written-example-1
User Yonigo
by
4.0k points