Skip to content

Commit 8c30b56

Browse files
Clarify bills in currency exchange exercise (#3520)
* 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 * Small Fixes from CI Fails Fixed some small argument name errors that were causing the CI to fail. Also sorted reflinks and touched up some language int he `hints.md` file and the instructions. [no important files changed] --------- Co-authored-by: Mett Mamoang <[email protected]> Co-authored-by: BethanyG <[email protected]>
1 parent c47870a commit 8c30b56

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

exercises/concept/currency-exchange/.docs/hints.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818

1919
## 4. Calculate number of bills
2020

21-
- You need to divide `budget` into `denomination`.
22-
- You need to use type casting to _int_ to get the exact number of bills.
21+
- You need to divide `amount` into `denomination`.
22+
- You need to use type casting to `int` to get the exact number of bills.
2323
- To remove decimal places from a `float`, you can convert it to `int`.
2424

2525
**Note:** The `//` operator also does floor division. But, if the operand has `float`, the result is still `float`.
2626

2727
## 5. Calculate leftover after exchanging into bills
2828

29-
- You need to find the remainder of `budget` that does not equal a whole `denomination`.
29+
- You need to find the remainder of `amount` that does not equal a whole `denomination`.
3030
- The Modulo operator `%` can help find the remainder.
3131

3232
## 6. Calculate value after exchange
3333

3434
- You need to calculate `spread` percent of `exchange_rate` using multiplication operator and add it to `exchange_rate` to get the exchanged currency.
35-
- The actual rate needs to be computed. Remember to add exchange rate and exchange fee.
36-
- You can get exchanged money affected by commission by using divide operation and type casting _int_.
35+
- The actual rate needs to be computed. Remember to add exchange _rate_ and exchange _fee_.
36+
- You can get exchanged money affected by commission by using divide operation and type casting to `int`.
3737

3838

39+
[division-operator]: https://docs.python.org/3/tutorial/introduction.html#numbers
40+
[multiplication-operator]: https://docs.python.org/3/tutorial/introduction.html#numbers
3941
[python-numbers-tutorial]: https://docs.python.org/3/tutorial/introduction.html#numbers
4042
[python-numeric-types]: https://docs.python.org/3.9/library/stdtypes.html#numeric-types-int-float-complex
41-
[division-operator]: https://docs.python.org/3/tutorial/introduction.html#numbers
4243
[subtraction-operator]: https://docs.python.org/3/tutorial/introduction.html#numbers
43-
[multiplication-operator]: https://docs.python.org/3/tutorial/introduction.html#numbers

exercises/concept/currency-exchange/.docs/instructions.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Create the `exchange_money()` function, taking 2 parameters:
1212
This function should return the value of the exchanged currency.
1313

1414
**Note:** If your currency is USD and you want to exchange USD for EUR with an exchange rate of `1.20`, then `1.20 USD == 1 EUR`.
15+
1516
```python
1617
>>> exchange_money(127.5, 1.2)
1718
106.25
@@ -36,7 +37,7 @@ This function should return the amount of money that *is left* from the budget.
3637
Create the `get_value_of_bills()` function, taking 2 parameters:
3738

3839
1. `denomination` : The value of a single bill.
39-
2. `number_of_bills` : Number of bills you received.
40+
2. `number_of_bills` : The total number of bills.
4041

4142
This exchanging booth only deals in cash of certain increments.
4243
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 +51,10 @@ Unfortunately, the booth gets to keep the remainder/change as an added bonus.
5051

5152
## 4. Calculate number of bills
5253

53-
Create the `get_number_of_bills()` function, taking `budget` and `denomination`.
54+
Create the `get_number_of_bills()` function, taking `amount` and `denomination`.
5455

55-
This function should return the _number of currency bills_ that you can receive within the given _budget_.
56-
In other words: How many _whole bills_ of currency fit into the amount of currency you have in your budget?
56+
This function should return the _number of currency bills_ that you can receive within the given _amount_.
57+
In other words: How many _whole bills_ of currency fit into the starting amount?
5758
Remember -- you can only receive _whole bills_, not fractions of bills, so remember to divide accordingly.
5859
Effectively, you are rounding _down_ to the nearest whole bill/denomination.
5960

@@ -64,9 +65,9 @@ Effectively, you are rounding _down_ to the nearest whole bill/denomination.
6465

6566
## 5. Calculate leftover after exchanging into bills
6667

67-
Create the `get_leftover_of_bills()` function, taking `budget` and `denomination`.
68+
Create the `get_leftover_of_bills()` function, taking `amount` and `denomination`.
6869

69-
This function should return the _leftover amount_ that cannot be exchanged from your _budget_ given the denomination of bills.
70+
This function should return the _leftover amount_ that cannot be returned from your starting _amount_ given the denomination of bills.
7071
It is very important to know exactly how much the booth gets to keep.
7172

7273
```python

exercises/concept/currency-exchange/.docs/introduction.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ To convert a float to an integer, you can use `int()`. Also, to convert an integ
7070
3.0
7171
```
7272

73-
[arbitrary-precision]: https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic#:~:text=In%20computer%20science%2C%20arbitrary%2Dprecision,memory%20of%20the%20host%20system.
74-
[numeric-type-docs]: https://docs.python.org/3/library/stdtypes.html#typesnumeric
75-
[`int()` built in]: https://docs.python.org/3/library/functions.html#int
76-
[`float()` built in]: https://docs.python.org/3/library/functions.html#float
7773
[0.30000000000000004.com]: https://0.30000000000000004.com/
74+
[`float()` built in]: https://docs.python.org/3/library/functions.html#float
75+
[`int()` built in]: https://docs.python.org/3/library/functions.html#int
76+
[arbitrary-precision]: https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic#:~:text=In%20computer%20science%2C%20arbitrary%2Dprecision,memory%20of%20the%20host%20system.
7877
[floating point math]: https://docs.python.org/3.9/tutorial/floatingpoint.html
78+
[numeric-type-docs]: https://docs.python.org/3/library/stdtypes.html#typesnumeric

exercises/concept/currency-exchange/.meta/exemplar.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,33 @@ def get_value_of_bills(denomination, number_of_bills):
2424
"""
2525
2626
:param denomination: int - the value of a bill.
27-
:param number_of_bills: int - number of bills you received.
28-
:return: int - total value of bills you now have.
27+
:param number_of_bills: int - total number of bills.
28+
:return: int - calculated value of the bills.
2929
"""
3030

3131
return denomination * number_of_bills
3232

3333

34-
def get_number_of_bills(budget, denomination):
34+
def get_number_of_bills(amount, denomination):
3535
"""
3636
37-
:param budget: float - the amount of money you are planning to exchange.
37+
:param amount: float - the total starting value.
3838
:param denomination: int - the value of a single bill.
39-
:return: int - number of bills after exchanging all your money.
39+
:return: int - number of bills that can be obtained from the amount.
4040
"""
4141

42-
return int(budget) // denomination
42+
return int(amount) // denomination
4343

4444

45-
def get_leftover_of_bills(budget, denomination):
45+
def get_leftover_of_bills(amount, denomination):
4646
"""
4747
48-
:param budget: float - the amount of money you are planning to exchange.
48+
:param amount: float - the total starting value.
4949
:param denomination: int - the value of a single bill.
50-
:return: float - the leftover amount that cannot be exchanged given the current denomination.
50+
:return: float - the amount that is "leftover", given the current denomination.
5151
"""
5252

53-
return budget % denomination
53+
return amount % denomination
5454

5555

5656
def exchangeable_value(budget, exchange_rate, spread, denomination):

exercises/concept/currency-exchange/exchange.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ def get_value_of_bills(denomination, number_of_bills):
2424
"""
2525
2626
:param denomination: int - the value of a bill.
27-
:param number_of_bills: int - number of bills you received.
28-
:return: int - total value of bills you now have.
27+
:param number_of_bills: int - total number of bills.
28+
:return: int - calculated value of the bills.
2929
"""
3030

3131
pass
3232

3333

34-
def get_number_of_bills(budget, denomination):
34+
def get_number_of_bills(amount, denomination):
3535
"""
3636
37-
:param budget: float - the amount of money you are planning to exchange.
37+
:param amount: float - the total starting value.
3838
:param denomination: int - the value of a single bill.
39-
:return: int - number of bills after exchanging all your money.
39+
:return: int - number of bills that can be obtained from the amount.
4040
"""
4141

4242
pass
4343

4444

45-
def get_leftover_of_bills(budget, denomination):
45+
def get_leftover_of_bills(amount, denomination):
4646
"""
4747
48-
:param budget: float - the amount of money you are planning to exchange.
48+
:param amount: float - the total starting value.
4949
:param denomination: int - the value of a single bill.
50-
:return: float - the leftover amount that cannot be exchanged given the current denomination.
50+
:return: float - the amount that is "leftover", given the current denomination.
5151
"""
5252

5353
pass

0 commit comments

Comments
 (0)