Skip to content
Merged
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
Next Next commit
refactor: provides type hint for parameters
  • Loading branch information
tarcisiobruni committed Oct 24, 2021
commit e00a8750012f61ee3194449a7d2a42b3b525c714
4 changes: 2 additions & 2 deletions financials/interest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

def simple_interest(principle, daily_interest_rate, number_of_days_between_payment) -> float:
def simple_interest(principle:float, daily_interest_rate:float, number_of_days_between_payment:int) -> float:
"""
>>> simple_interest(18000,0.06,3)
3240.0
Copy link
Copy Markdown
Member

@cclauss cclauss Oct 24, 2021

Choose a reason for hiding this comment

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

Add tests dealing with zero principle, negative principle, zero interest rate, negative interest rate, zero days, negative days, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cclauss done

"""
result = principle * daily_interest_rate * number_of_days_between_payment
return result

def compound_interest(principle, nominal_annual_interest_rate_percentage , number_of_compounding_periods)-> float:
def compound_interest(principle:float, nominal_annual_interest_rate_percentage:float, number_of_compounding_periods:int)-> float:
"""
>>> compound_interest(10000,0.05,3)
1576.2500000000014
Expand Down