[Currency Exchange] [Python] Incongruence between instruction #4 and expected solution behavior

On instructions.md, the instruction number 4 states that the function should answer to the question: “How many whole_bills of new currency fit into the amount of old currency you have in your budget?,” the solution for this requires that we first make a currency exchange of the (old currency) budget, then we would need to calculate how many bills of the new currency fit into the exchanged (new currency) budget. However, in the code on exchange.py and in the tests regarding the get_number_of_bills() function on exchange_test.py the expected solution doesn’t contemplate the needed exchange_rate parameter to fulfill the correct answer to the instruction.
Either, the instruction should be changed to ask for the number of bills between a budget and a denomination of the same currency or the function signature and corresponding tests should be modified to include the exchange_rate parameter.

That question is meant to be read in the broader context of “he wants you to make a currency calculator for him”. The idea is that all these functions are being used for currency conversions. The only reason you’d want to calculate bills is because someone started with an old currency (which, say, was a nice round number, a multiplier of some denomination) which was already converted to a new currency, budget. Since there was a conversion, the budget is no longer a clean, round number. Now that budget needs to be paid out in one denomination.

Concept exercise tasks are part of an overall story and often need to be read in context. In isolation, they often don’t make a whole lot of sense.

Could the task be more explicit and clear and make sense without context? For sure.

Is there a bug? No. Repeating the whole story for each task would make the prose rather repetitive.

@luisvra would removal of “old” and "new " from the instructions solve your problem?

Result of suggested modification

4. Calculate number of bills

Create the get_number_of_bills() function, taking budget and denomination.

This function should return the number of currency bills that you can receive within the given budget. In other words: How many whole bills of currency fit into the amount of currency you have in your budget? 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.

>>> get_number_of_bills(127.5, 5)
1 Like

@MatthijsBlom Yes, I think this would solve the problem keeping the exercise simple and improving its clarity.

@MatthijsBlom - care to PR that? :smile: If it auto-closes, I’ll reopen it.

I strongly agree with your following affirmation “Concept exercise tasks are part of an overall story and often need to be read in context. In isolation, they often don’t make a whole lot of sense.” But the instruction #4 explicitly states that the expected behavior is to take in a budget in the old currency and that the bills denomination is in terms of the new currency. I believe this instruction is misleading and, in my opinion, could cause confusion to beginners.

PR: Clarify Currency Exchange instructions by MatthijsBlom · Pull Request #3316 · exercism/python · GitHub

I did not check for similar problems elsewhere in the same file.


Reviewed and merged. Thank you, @MatthijsBlom :smile:

1 Like