-
-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
michaelnathanroberts
wants to merge
12
commits into
TheAlgorithms:master
Choose a base branch
from
michaelnathanroberts:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Expand depreciation #12808
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6d242b2
Expand depreciation
michaelnathanroberts b439b9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8737768
Add examples
michaelnathanroberts c7fab6e
Merge remote-tracking branch 'refs/remotes/origin/master'
michaelnathanroberts ef9c3c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a8764d9
Fix db depreciation
michaelnathanroberts 5c05b65
Merge branch 'master' of github.com:michaelnathanroberts/TheAlgorithm…
michaelnathanroberts 5e03f63
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6982b76
reformat
michaelnathanroberts 02ec03b
Reformat, pt. 2
michaelnathanroberts 4a8166a
resolve merge conflict
michaelnathanroberts 59488a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
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
commit 59488a284d4e56d74d28404424f3d14571f8651c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,14 +94,15 @@ def straight_line_depreciation( | |
def declining_balance_depreciation( | ||
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) | ||
|
@@ -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 | ||
|
@@ -150,14 +151,15 @@ def declining_balance_depreciation( | |
def sum_of_years_digits_depreciation( | ||
9269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: |
||
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) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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: