8000 Expand depreciation by michaelnathanroberts · Pull Request #12808 · TheAlgorithms/Python · GitHub
[go: up one dir, main page]

Skip to content

Expand depreciation #12808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 26, 2025
commit 59488a284d4e56d74d28404424f3d14571f8651c
12 changes: 7 additions & 5 deletions financial/depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ def straight_line_depreciation(
def declining_balance_depreciation(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: declining_balance_depreciation. If the function does not return a value, please provide the type hint as: def function() -> None:

useful_years: int,
purchase_value: float,
residual_value: float = 0.0,) -> list[float]:
residual_value: float = 0.0,
) -> list[float]:
"""
Calculate the depreciation expenses over the given period,
using the declining balance method
:param useful_years: Number of years the asset will be used
:param purchase_value: Purchase expenditure for the asset
:param residual_value: Residual value of the asset at the end of its useful life
:return: A list of annual depreciation expenses over the asset's useful life,
:return: A list of annual depreciation expenses over the asset's useful life,
rounded to the nearest cent

>>> declining_balance_depreciation(10,1100.0,100.0)
Expand Down Expand Up @@ -139,7 +140,7 @@ def declining_balance_depreciation(

list_of_depreciation_expenses = []

for _ in range(1, useful_years+1):
for _ in range(1, useful_years + 1):
new_book_value = book_value * (1 - depreciation_rate)
list_of_depreciation_expenses.append(round(book_value - new_book_value, 2))
book_value = new_book_value
Expand All @@ -150,14 +151,15 @@ def declining_balance_depreciation(
def sum_of_years_digits_depreciation(
9269

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: sum_of_years_digits_depreciation. If the function does not return a value, please provide the type hint as: def function() -> None:

useful_years: int,
purchase_value: float,
residual_value: float = 0.0,) -> list[float]:
residual_value: float = 0.0,
) -> list[float]:
"""
Calculate the depreciation expenses over the given period,
using the sum of years' digits method
:param useful_years: Number of years the asset will be used
:param purchase_value: Purchase expenditure for the asset
:param residual_value: Residual value of the asset at the end of its useful life
:return: A list of annual depreciation expenses over the asset's useful life,
:return: A list of annual depreciation expenses over the asset's useful life,
rounded to the nearest cent

>>> sum_of_years_digits_depreciation(10,1100.0,100.0)
Expand Down
Loading
0