From fc8dbdfef86b94372920220db61606169943e7f4 Mon Sep 17 00:00:00 2001 From: Mett Mamoang Date: Fri, 20 Oct 2023 09:38:58 +0200 Subject: [PATCH] Clarify bills in currency exchange exercise The exchange booth in this exercise only deals in cash of specific increments. That is to say, you can bring any combination of bills and coins to exchange, but you get a collection of bills of a single denomination in the target currency in return. The explanation was quite clear on this, but the parameter names and docstrings in the methods dealing with this part of the task used the term 'budget', which could lead readers to assume that the bills had to do with the original currency. This reworks the methods related to bills to be more generic, not referring to the exchange process at all, hopefully avoiding this misinterpretation. See forum thread here for details of the discussion leading to this change: https://forum.exercism.org/t/currency-exchange-exercise-suggested-naming-tweaks/7790 --- .../concept/currency-exchange/.docs/hints.md | 4 ++-- .../currency-exchange/.docs/instructions.md | 12 ++++++------ .../concept/currency-exchange/.meta/exemplar.py | 16 ++++++++-------- exercises/concept/currency-exchange/exchange.py | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/exercises/concept/currency-exchange/.docs/hints.md b/exercises/concept/currency-exchange/.docs/hints.md index b54f0d345f..b9f299349d 100644 --- a/exercises/concept/currency-exchange/.docs/hints.md +++ b/exercises/concept/currency-exchange/.docs/hints.md @@ -18,7 +18,7 @@ ## 4. Calculate number of bills -- You need to divide `budget` into `denomination`. +- You need to divide `amount` into `denomination`. - You need to use type casting to _int_ to get the exact number of bills. - To remove decimal places from a `float`, you can convert it to `int`. @@ -26,7 +26,7 @@ ## 5. Calculate leftover after exchanging into bills -- You need to find the remainder of `budget` that does not equal a whole `denomination`. +- You need to find the remainder of `amount` that does not equal a whole `denomination`. - The Modulo operator `%` can help find the remainder. ## 6. Calculate value after exchange diff --git a/exercises/concept/currency-exchange/.docs/instructions.md b/exercises/concept/currency-exchange/.docs/instructions.md index adce534931..72dcea1308 100644 --- a/exercises/concept/currency-exchange/.docs/instructions.md +++ b/exercises/concept/currency-exchange/.docs/instructions.md @@ -36,7 +36,7 @@ This function should return the amount of money that *is left* from the budget. Create the `get_value_of_bills()` function, taking 2 parameters: 1. `denomination` : The value of a single bill. -2. `number_of_bills` : Number of bills you received. +2. `number_of_bills` : The total number of bills. 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. @@ -50,10 +50,10 @@ Unfortunately, the booth gets to keep the remainder/change as an added bonus. ## 4. Calculate number of bills -Create the `get_number_of_bills()` function, taking `budget` and `denomination`. +Create the `get_number_of_bills()` function, taking `amount` 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? +This function should return the _number of currency bills_ that you can receive within the given _amount_. +In other words: How many _whole bills_ of currency fit into the starting amount? 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. @@ -64,9 +64,9 @@ Effectively, you are rounding _down_ to the nearest whole bill/denomination. ## 5. Calculate leftover after exchanging into bills -Create the `get_leftover_of_bills()` function, taking `budget` and `denomination`. +Create the `get_leftover_of_bills()` function, taking `amount` and `denomination`. -This function should return the _leftover amount_ that cannot be exchanged from your _budget_ given the denomination of bills. +This function should return the _leftover amount_ that cannot be returned from your starting _amount_ given the denomination of bills. It is very important to know exactly how much the booth gets to keep. ```python diff --git a/exercises/concept/currency-exchange/.meta/exemplar.py b/exercises/concept/currency-exchange/.meta/exemplar.py index 99ba5d2626..0b464076f8 100644 --- a/exercises/concept/currency-exchange/.meta/exemplar.py +++ b/exercises/concept/currency-exchange/.meta/exemplar.py @@ -24,30 +24,30 @@ def get_value_of_bills(denomination, number_of_bills): """ :param denomination: int - the value of a bill. - :param number_of_bills: int - number of bills you received. - :return: int - total value of bills you now have. + :param number_of_bills: int - total number of bills. + :return: int - calculated value of the bills. """ return denomination * number_of_bills -def get_number_of_bills(budget, denomination): +def get_number_of_bills(amount, denomination): """ - :param budget: float - the amount of money you are planning to exchange. + :param amount: float - the total starting value. :param denomination: int - the value of a single bill. - :return: int - number of bills after exchanging all your money. + :return: int - number of bills that can be obtained from the amount. """ return int(budget) // denomination -def get_leftover_of_bills(budget, denomination): +def get_leftover_of_bills(amount, denomination): """ - :param budget: float - the amount of money you are planning to exchange. + :param amount: float - the total starting value. :param denomination: int - the value of a single bill. - :return: float - the leftover amount that cannot be exchanged given the current denomination. + :return: float - the amount that is "leftover", given the current denomination. """ return budget % denomination diff --git a/exercises/concept/currency-exchange/exchange.py b/exercises/concept/currency-exchange/exchange.py index 33454dc54a..e05c7bcc54 100644 --- a/exercises/concept/currency-exchange/exchange.py +++ b/exercises/concept/currency-exchange/exchange.py @@ -24,30 +24,30 @@ def get_value_of_bills(denomination, number_of_bills): """ :param denomination: int - the value of a bill. - :param number_of_bills: int - number of bills you received. - :return: int - total value of bills you now have. + :param number_of_bills: int - total number of bills. + :return: int - calculated value of the bills. """ pass -def get_number_of_bills(budget, denomination): +def get_number_of_bills(amount, denomination): """ - :param budget: float - the amount of money you are planning to exchange. + :param amount: float - the total starting value. :param denomination: int - the value of a single bill. - :return: int - number of bills after exchanging all your money. + :return: int - number of bills that can be obtained from the amount. """ pass -def get_leftover_of_bills(budget, denomination): +def get_leftover_of_bills(amount, denomination): """ - :param budget: float - the amount of money you are planning to exchange. + :param amount: float - the total starting value. :param denomination: int - the value of a single bill. - :return: float - the leftover amount that cannot be exchanged given the current denomination. + :return: float - the amount that is "leftover", given the current denomination. """ pass