Drill

ProblemsPython › billing

Calculate tax on a shipping charge

easybillingPython

Some regions tax shipping, others do not. Compute the tax amount on a shipping cost.

tax_on_shipping(shipping_cost: int, tax_percent: int, taxable: bool) → int

Solve it in the editor →

Where you start

def tax_on_shipping(shipping_cost: int, tax_percent: int, taxable: bool) -> int:
    

Worked examples

CallResult
tax_on_shipping(8000, 10, True)800
tax_on_shipping(8000, 10, False)0
tax_on_shipping(0, 20, True)0
tax_on_shipping(5500, 8, True)440

Hint

One conditional and an integer division.

Reference solution in Python
def tax_on_shipping(shipping_cost: int, tax_percent: int, taxable: bool) -> int:
    if not taxable:
        return 0
    return shipping_cost * tax_percent // 100

The same problem in another language

More billing problems in Python