Problem understanding "currency exhange" exercise

``````Code Run
test_data = [(100000, 10.61, 10, 1),
(1500, 0.84, 25, 40),
(470000, 1050, 30, 10000000000),
(470000, 0.00000009, 30, 700),
(425.33, 0.0009, 30, 700)]

result_data = [8568, 1400, 0, 4017094016600, 363300]

for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
budget, exchange_rate, spread, denomination = params

with self.subTest(f"variation #{variant}",
budget=budget,
exchange_rate=exchange_rate,
denomination=denomination,
expected=expected):

actual_result = exchangeable_value(budget, exchange_rate, spread, denomination)
error_message = (f'Called exchangeable_value{budget, exchange_rate, spread, denomination}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} as the maximum '
f'value of the new currency .')

self.assertEqual(actual_result, expected, msg=error_message)
Test Failure
One or more variations of this test failed. Details can be found under each [variant#].
``````

The previous is wrong in the function:

``````def exchangeable_value(budget, exchange_rate, spread, denomination):
"""
:param budget: float - the amount of your money you are planning to exchange.
:param exchange_rate: float - the unit value of the foreign currency.

:param spread: int - percentage that is taken as an exchange fee.
:param denomination: int - the value of a single bill.
:return: int - maximum value you can get.
"""
# Cantidad en la divisa objetivo antes de la tarifa
cantidad_cambio = budget * exchange_rate

# Costo de la tarifa
tarifa = cantidad_cambio * (spread / 100)

# Cantidad despues de aplicar la tarifa

# Numero maximo de billetes completos
maximo_billetes = cantidad_despues_tarifa // denomination

return int(maximo_billetes)
``````

I cannot find for this function… Could you help me with that?

You want to scroll down to the next TEST FAILURE* and click on it to expand it. The variants will have much more clear results.

``````Code Run
test_data = [(100000, 10.61, 10, 1),
(1500, 0.84, 25, 40),
(470000, 1050, 30, 10000000000),
(470000, 0.00000009, 30, 700),
(425.33, 0.0009, 30, 700)]

result_data = [8568, 1400, 0, 4017094016600, 363300]

for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
budget, exchange_rate, spread, denomination = params

with self.subTest(f"variation #{variant}",
budget=budget,
exchange_rate=exchange_rate,
denomination=denomination,
expected=expected):

actual_result = exchangeable_value(budget, exchange_rate, spread, denomination)
error_message = (f'Called exchangeable_value{budget, exchange_rate, spread, denomination}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} as the maximum '
f'value of the new currency .')

self.assertEqual(actual_result, expected, msg=error_message)
Test Failure
AssertionError: 954900 != 8568 : Called exchangeable_value(100000, 10.61, 10, 1). The function returned 954900, but The tests expected 8568 as the maximum value of the new currency .
``````

IsaacG, my problem is to make the formula to solve the problem…

Your code looks like it is mostly doing the right thing. Except you’re returning the number of the bills when you should be returning the value of the bills.