Skip to content

Commit 7de4681

Browse files
authored
Updated stub docstrings to Google Style. (#4150)
1 parent 2ed15de commit 7de4681

1 file changed

Lines changed: 110 additions & 26 deletions

File tree

exercises/concept/currency-exchange/exchange.py

Lines changed: 110 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,152 @@
88

99

1010
def exchange_money(budget, exchange_rate):
11-
"""
11+
"""Calculate estimated value after exchange.
12+
13+
Parameters:
14+
budget (float): Tthe amount of money you are planning to exchange.
15+
exchange_rate (float): The unit value of the foreign currency.
16+
17+
Returns:
18+
float: The exchanged value of the foreign currency you can receive.
19+
20+
Examples:
21+
>>> exchange_money(127.5, 1.2)
22+
106.25
23+
24+
>>> exchange_money(200, 1.10)
25+
181.82
26+
27+
This function calculates and returns the (estimated) value of the exchanged currency.
1228
13-
:param budget: float - amount of money you are planning to exchange.
14-
:param exchange_rate: float - unit value of the foreign currency.
15-
:return: float - exchanged value of the foreign currency you can receive.
1629
"""
1730

1831
pass
1932

2033

2134
def get_change(budget, exchanging_value):
22-
"""
35+
"""Calculate currency left after an exchange.
36+
37+
Parameters:
38+
budget (float): The amount of money you own.
39+
exchanging_value (float): The amount of your money you want to exchange now.
40+
41+
Returns:
42+
float: The amount left of your starting currency after the exchange
43+
44+
Examples:
45+
.>>> get_change(127.5, 120.0)
46+
7.5
47+
48+
>>> get_change(300.75, 150.25)
49+
150.50
50+
51+
Tthis function calcultes and returns the amount of money left over from the budget
52+
after an exchange.
2353
24-
:param budget: float - amount of money you own.
25-
:param exchanging_value: float - amount of your money you want to exchange now.
26-
:return: float - amount left of your starting currency after exchanging.
2754
"""
2855

2956
pass
3057

3158

3259
def get_value_of_bills(denomination, number_of_bills):
33-
"""
60+
"""Calculate the total value of currency at current denomination.
61+
62+
Parameters:
63+
denomination (int): The value of a single unit (bill).
64+
number_of_bills (int): The total number of units (bills).
65+
66+
Returns:
67+
int: Calculated value of the units (bills).
68+
69+
Examples:
70+
>>> get_value_of_bills(5, 128)
71+
640
72+
73+
>>> get_value_of_bills(15.13, 16)
74+
242
75+
76+
This function calculates and returns the total value of the bills (excluding fractionaal amounts).
3477
35-
:param denomination: int - the value of a bill.
36-
:param number_of_bills: int - total number of bills.
37-
:return: int - calculated value of the bills.
3878
"""
3979

4080
pass
4181

4282

4383
def get_number_of_bills(amount, denomination):
44-
"""
84+
"""Calculate the number of currency units (bills) within the amount.
85+
86+
Parameters:
87+
amount (float): The total starting value.
88+
denomination (int): The value of a single unit (bill).
89+
90+
Returns:
91+
int: The number of units (bills) that can be obtained from the amount.
92+
93+
Examples:
94+
>>> get_number_of_bills(127.5, 5)
95+
25
96+
97+
>>> get_number_of_bills(35.16, 10)
98+
3
99+
100+
This function calcluates and returns the number pf currency units (bills) that can
101+
be obtained from the given amount. Whole bills only - no fractioal amounts.
45102
46-
:param amount: float - the total starting value.
47-
:param denomination: int - the value of a single bill.
48-
:return: int - number of bills that can be obtained from the amount.
49103
"""
50104

51105
pass
52106

53107

54108
def get_leftover_of_bills(amount, denomination):
55-
"""
109+
"""Calculate leftover amount after exchanging into bills.
110+
111+
Parameters:
112+
amount (float): The total starting value.
113+
denomination (int): The value of a single unit (bill).
114+
115+
Returns:
116+
float: The amount that is "leftover", given the current denomination.
117+
118+
Examples:
119+
>>> get_leftover_of_bills(127.5, 20)
120+
7.5
121+
122+
>>> get_leftover_of_bills(153.2, 10)
123+
3.20
124+
125+
This function calculates and returns the leftover amount that cannot be
126+
returned from starting amount, due to the currency denomination.
56127
57-
:param amount: float - the total starting value.
58-
:param denomination: int - the value of a single bill.
59-
:return: float - the amount that is "leftover", given the current denomination.
60128
"""
61129

62130
pass
63131

64132

65133
def exchangeable_value(budget, exchange_rate, spread, denomination):
66-
"""
134+
"""Calculate the maximum value of the new currency.
135+
136+
Parameters:
137+
budget (float): The amount of your money you are planning to exchange.
138+
exchange_rate (float): The unit value of the foreign currency.
139+
spread (int): The percentage that is taken as an exchange fee.
140+
denomination (int) The value of a single unit (bill).
141+
142+
Returns:
143+
int: The maximum value you can get in the new currency.
144+
145+
Examples:
146+
>>> exchangeable_value(127.25, 1.20, 10, 20)
147+
80
148+
149+
>>> exchangeable_value(127.25, 1.20, 10, 5)
150+
95
151+
152+
Note:
153+
The currency denomination is a whole number and cannot be sub-divided.
67154
68-
:param budget: float - the amount of your money you are planning to exchange.
69-
:param exchange_rate: float - the unit value of the foreign currency.
70-
:param spread: int - percentage that is taken as an exchange fee.
71-
:param denomination: int - the value of a single bill.
72-
:return: int - maximum value you can get.
155+
This function calculates and returns the maximum value of the new currency after
156+
determining the exchange rate plus the spread.
73157
"""
74158

75159
pass

0 commit comments

Comments
 (0)