66
77 0: $1000 --- 1: $1000 --- 2: $1000 --- 3: no payment
88
9- The following function, get_annuity_due_future_value , gives the future value of
9+ The following function, annuity_due_future_value , gives the future value of
1010the given annuity due. In the example above, the function should return
1111the sum of each payment's future value at the end of term 3.
1212
1313More info on: https://www.investopedia.com/retirement/calculating-present-and-future-value-of-annuities
1414
15- This function can help to understand how much you will receive
15+ This function can help you understand how much you will receive
1616if you make a regular deposit at the beginning of each term
17- for saving with a fix period and interest rate.
17+ for saving with a fixed period and interest rate.
1818"""
1919
2020
21- def get_annuity_due_future_value (
21+ def annuity_due_future_value (
2222 term_payment : float , number_of_payments : int , term_interest_rate : float
2323) -> float :
2424 """
@@ -29,13 +29,13 @@ def get_annuity_due_future_value(
2929 :return: the future value (maturity value) of the given annuity due
3030
3131 Examples:
32- >>> round(get_annuity_due_future_value (500, 10, 0.05), 2)
32+ >>> round(annuity_due_future_value (500, 10, 0.05), 2)
3333 6603.39
34- >>> round(get_annuity_due_future_value (1000, 10, 0.05), 2)
34+ >>> round(annuity_due_future_value (1000, 10, 0.05), 2)
3535 13206.79
36- >>> round(get_annuity_due_future_value (1000, 10, 0.10), 2)
36+ >>> round(annuity_due_future_value (1000, 10, 0.10), 2)
3737 17531.17
38- >>> round(get_annuity_due_future_value (1000, 20, 0.10), 2)
38+ >>> round(annuity_due_future_value (1000, 20, 0.10), 2)
3939 63002.5
4040 """
4141
@@ -47,11 +47,14 @@ def get_annuity_due_future_value(
4747
4848
4949if __name__ == "__main__" :
50+ from doctest import testmod
51+
52+ testmod ()
5053 user_input_amount = float (input ("How much money will be deposited each term?\n > " ))
5154 user_input_payment_number = int (input ("How many payments will be made?\n > " ))
5255 term_interest_rate = float (input ("What is the interest rate per term?\n > " ))
5356 print (
54- get_annuity_due_future_value (
57+ annuity_due_future_value (
5558 user_input_amount , user_input_payment_number , term_interest_rate
5659 )
5760 )
0 commit comments