Drill

ProblemsPython › finance

Price per unit

easyfinancePython

A bulk bin lists a total for a quantity of identical items. What does a single unit cost?

price_per_unit(total_minor: int, quantity: int) → int

Solve it in the editor →

Where you start

def price_per_unit(total_minor: int, quantity: int) -> int:
    

Worked examples

CallResult
price_per_unit(1000, 4)250
price_per_unit(1000, 3)333
price_per_unit(100, 10)10
price_per_unit(0, 5)0

Hint

Divide and drop the remainder.

Reference solution in Python
def price_per_unit(total_minor: int, quantity: int) -> int:
    if quantity <= 0:
        return 0
    return total_minor // quantity

The same problem in another language

More finance problems in Python