From cb4dc197238e670d150eaebd8f387670f7a54377 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 26 Oct 2021 18:41:32 +0200 Subject: [PATCH] Financial: principle -> principal (#5614) * Financial: principle -> principal The originally invested amount of money: `principal` -- https://www.grammarly.com/blog/principle-principal/ * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- DIRECTORY.md | 4 ++++ financial/interest.py | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 67f2113ea..6fbd5e2cc 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -129,6 +129,7 @@ * [Rgb Hsv Conversion](https://github.com/TheAlgorithms/Python/blob/master/conversions/rgb_hsv_conversion.py) * [Roman Numerals](https://github.com/TheAlgorithms/Python/blob/master/conversions/roman_numerals.py) * [Temperature Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/temperature_conversions.py) + * [Volume Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/volume_conversions.py) * [Weight Conversion](https://github.com/TheAlgorithms/Python/blob/master/conversions/weight_conversion.py) ## Data Structures @@ -290,6 +291,9 @@ * Tests * [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py) +## Financial + * [Interest](https://github.com/TheAlgorithms/Python/blob/master/financial/interest.py) + ## Fractals * [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py) * [Koch Snowflake](https://github.com/TheAlgorithms/Python/blob/master/fractals/koch_snowflake.py) diff --git a/financial/interest.py b/financial/interest.py index 394da2bc9..c69c73045 100644 --- a/financial/interest.py +++ b/financial/interest.py @@ -4,7 +4,7 @@ from __future__ import annotations def simple_interest( - principle: float, daily_interest_rate: float, days_between_payments: int + principal: float, daily_interest_rate: float, days_between_payments: int ) -> float: """ >>> simple_interest(18000.0, 0.06, 3) @@ -24,7 +24,7 @@ def simple_interest( >>> simple_interest(-10000.0, 0.06, 3) Traceback (most recent call last): ... - ValueError: principle must be > 0 + ValueError: principal must be > 0 >>> simple_interest(5500.0, 0.01, -5) Traceback (most recent call last): ... @@ -34,13 +34,13 @@ def simple_interest( raise ValueError("days_between_payments must be > 0") if daily_interest_rate < 0: raise ValueError("daily_interest_rate must be >= 0") - if principle <= 0: - raise ValueError("principle must be > 0") - return principle * daily_interest_rate * days_between_payments + if principal <= 0: + raise ValueError("principal must be > 0") + return principal * daily_interest_rate * days_between_payments def compound_interest( - principle: float, + principal: float, nominal_annual_interest_rate_percentage: float, number_of_compounding_periods: int, ) -> float: @@ -62,16 +62,16 @@ def compound_interest( >>> compound_interest(-5500.0, 0.01, 5) Traceback (most recent call last): ... - ValueError: principle must be > 0 + ValueError: principal must be > 0 """ if number_of_compounding_periods <= 0: raise ValueError("number_of_compounding_periods must be > 0") if nominal_annual_interest_rate_percentage < 0: raise ValueError("nominal_annual_interest_rate_percentage must be >= 0") - if principle <= 0: - raise ValueError("principle must be > 0") + if principal <= 0: + raise ValueError("principal must be > 0") - return principle * ( + return principal * ( (1 + nominal_annual_interest_rate_percentage) ** number_of_compounding_periods - 1 )