Quick actions

cmd+k|ctrl+k

Navigation

Languages

BranchingConditionalsExamples

Snippet info

Language

Python

Visibility

public

Author

masterhun

Created

2023-11-17T19:46:31.280388Z

Updated

2024-01-01T19:59:38.190659Z


print("Time to pay your (federal) income tax!")

print()

taxable_income = int(input("Enter your total taxable income (dollars only): "))

print(taxable_income)

# If your taxable income was exactly $11,000, 
# then your income tax would be $1,100. 
tier1 = int( 11000 * 0.10 ) 

# If your taxable income was exactly $44,725, 
# then your income tax would be $1,100 + 
# ( 44725 - 11000 ) x 12% 
tier2 = int( ( 44725 - 11000 ) * 0.12 )

# tier1 + tier2 == $5,147

# print(str(tier1 + tier2))     # Output: 5147 

# Python elif is the contraction of else and if.
# Read elif as "else if".


if taxable_income > 44725 and taxable_income <= 95375:
    income_tax = tier1 + tier2 + ( ( taxable_income - 44725 ) * 0.22 ) 
elif taxable_income > 11000 and taxable_income <= 44725:
    income_tax = tier1 + ( ( taxable_income - 11000 ) * 0.12 )
elif taxable_income <= 11000:
    income_tax = taxable_income * 0.10
else:
    print("Error!!")
    
# We want income_tax to be an int (an integer, a whole number, no fractions).
income_tax = int( income_tax )

print() 

print("Your total (federal) income tax is " + str(income_tax))

INFO