Drill

ProblemsPython › finance

Convert between currencies

easyfinancePython

A money-changer converts an amount in minor units at a rate quoted in basis points (per ten thousand).

currency_convert(amount_minor: int, rate_bps: int) → int

Solve it in the editor →

Where you start

def currency_convert(amount_minor: int, rate_bps: int) -> int:
    

Worked examples

CallResult
currency_convert(1000, 8000)800
currency_convert(500, 10000)500
currency_convert(1250, 3333)416
currency_convert(0, 5000)0

Hint

Multiply then divide by 10000, rounding down.

Reference solution in Python
def currency_convert(amount_minor: int, rate_bps: int) -> int:
    return amount_minor * rate_bps // 10000

The same problem in another language

More finance problems in Python