P
P
Python Classroom
Ask or search…
K

nested if Problems

Problem 1

Write Python code that asks the user if they are filing what status they are filing as. The choices are:
  • Single
  • Married Filing Jointly
  • Head of Household
Ask the user what their income was. Subtract the appropriate deduction. Note: Married Filing Separately has the same standard deduction as single.
Print the amount of tax due.
Source: Kiplinger
Source: Kiplinger
Source: Kiplinger

Problem 2

These rates apply to the Lincoln & Holland tunnels, the George Washington, Bayonne & Goethals bridges, and the Outerbridge Crossing.
Write Python code to determine the amount of money you pay at the toll depending on:
  • Vehicle Type
  • The number of axels
  • EZPass Off Peak Hours
  • EZPass Peak Hours
  • EZPass
  • Cash
Peak Hours
  • Weekdays: 6-10 a.m., 4-8 p.m.
  • Sat. & Sun.: 11 a.m.-9 p.m.
Off-Peak Hours
  • All Other Times
Overnight Hours for Trucks
  • Sundays-Thursdays, 10 p.m. until 6 a.m. the following morning
Source: The Port Authority of New York and New Jersey