162k views
4 votes
Convert the following pseudocode to a Python program. Name the file

income. (Do not add an extension py to the file name. Python will add
the extension to the file name). Submit the file.
Input yearly income
if yearlyIncome is less than 40000
STANDARD_DEDUCTION = 10000
taxRate = 0.2
else
STANDARD DEDUCTION= 8000
taxRate = 0.3.
taxablelncome = yearlyIncome - STANDARD DEDUCTION
incomeTax = taxablelncome * taxRate
print income tax with the format "Income tax is...." + incomeTax
Sample output:
Enter yearly income: 50000
Income tax is $12600.0.

User Hiroshi
by
8.1k points

2 Answers

2 votes
# Get input for yearly income
yearlyIncome = float(input("Enter yearly income: "))

# Check if yearly income is less than 40000
if yearlyIncome < 40000:
STANDARD_DEDUCTION = 10000
taxRate = 0.2
else:
STANDARD_DEDUCTION = 8000
taxRate = 0.3

# Calculate taxable income and income tax
taxableIncome = yearlyIncome - STANDARD_DEDUCTION
incomeTax = taxableIncome * taxRate

# Print the income tax with the specified format
print("Income tax is: ${:.2f}".format(incomeTax))



Save the above code in a file named "income" (without any file extension) and run it using a Python interpreter. It will prompt the user to enter the yearly income, calculate the income tax based on the given conditions, and print the result with the specified format.
User Cesarsalgado
by
8.9k points
4 votes

Answer: yearly_income = float(input("Enter yearly income: "))

if yearly_income < 40000:

STANDARD_DEDUCTION = 10000

tax_rate = 0.2

else:

STANDARD_DEDUCTION = 8000

tax_rate = 0.3

taxable_income = yearly_income - STANDARD_DEDUCTION

income_tax = taxable_income * tax_rate

print("Income tax is $%.1f." % income_tax)

Step-by-step explanation:

User Tim Vermeulen
by
8.8k points