8000 Add examples · TheAlgorithms/Python@8737768 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8737768

Browse files
Add examples
1 parent 6d242b2 commit 8737768

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

financial/depreciation.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ def declining_balance_depreciation(useful_years: int,
9898
:param purchase_value: Purchase expenditure for the asset
9999
:param residual_value: Residual value of the asset at the end of its useful life
100100
:return: A list of annual depreciation expenses over the asset's useful life
101+
102+
>>> declining_balance_depreciation(10,1100.0,100.0)
103+
[234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077]
104+
>>> declining_balance_depreciation(6,1250.0,50.0)
105+
[518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485]
106+
>>> declining_balance_depreciation(4,1001.0)
107+
[1001.0, 0.0, 0.0, 0.0]
108+
>>> declining_balance_depreciation(11,380.0,50.0)
109+
[63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142]
110+
>>> declining_balance_depreciation(1,4985,100)
111+
[4885.0]
101112
"""
102113

103114
if not isinstance(useful_years, int):
@@ -139,6 +150,17 @@ def sum_of_years_digits_depreciation(useful_years: int,
139150
:param purchase_value: Purchase expenditure for the asset
140151
:param residual_value: Residual value of the asset at the end of its useful life
141152
:return: A list of annual depreciation expenses over the asset's useful life
153+
154+
>>> declining_balance_depreciation(10,1100.0,100.0)
155+
[234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077]
156+
>>> declining_balance_depreciation(6,1250.0,50.0)
157+
[518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485]
158+
>>> declining_balance_depreciation(4,1001.0)
159+
[1001.0, 0.0, 0.0, 0.0]
160+
>>> declining_balance_depreciation(11,380.0,50.0)
161+
[63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142]
162+
>>> declining_balance_depreciation(1,4985,100)
163+
[4885.0]
142164
"""
143165

144166
if not isinstance(useful_years, int):
@@ -171,10 +193,6 @@ def sum_of_years_digits_depreciation(useful_years: int,
171193
return list_of_depreciation_expenses
172194

173195

174-
175-
176-
177196
if __name__ == "__main__":
178197
import doctest
179-
180-
doctest.testmod()
198+
doctest.testmod()

0 commit comments

Comments
 (0)
0