#Struggling with solving Task 6 of Currency Exchange in Python

8 messages · Page 1 of 1 (latest)

naive grove
#

I have tried my best to understand the question and tried the following approach

Since we have an exchange fee, the actual rate of exchanging now becomes
Effective rate = Exchange_rate*(1 + exchange_fee_percentage)

Then I calculated how much money we can get by using a previous function
Essentially budget / effective_rate

Then the denomination is factored in

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.
    """
    spread_percent = spread / 100
    effective_rate = exchange_rate * (1 + spread_percent)

    money_we_can_get_on_exchange = exchange_money(budget, effective_rate)

    return int(money_we_can_get_on_exchange / denomination)
loud lantern
#

What's the last line compute?

naive grove
#

Hi
I didn't get you?

viscid falcon
#

This is my personal opinion, but to solve this task, it is necessary to thoroughly understand the instructions.

Instruction
This exchanging booth only deals in cash of certain increments. The total you receive must be divisible by the value of one "bill" or unit, which can leave behind a fraction or remainder. Your function should return only the total value of the bills (excluding fractional amounts) the booth would give back. Unfortunately, the booth gets to keep the remainder/change as an added bonus.
Instruction
Remember -- you can only receive whole bills, not fractions of bills, so remember to divide accordingly. Effectively, you are rounding down to the nearest whole bill/denomination.

You calculated money_we_can_get_on_exchange using budget and effective_rate.

For example, if you try to exchange $65 at an exchange booth that only deals with $20 bills, how much will you get back? How would you calculate this?

loud lantern
naive grove
#

oh let me try again

naive grove
#

Solved!!

viscid falcon
#

Congratulations! 🎉