The following function is given to calculate the future value (fv) of capital (pv) in the n periodic compound capitalization model with the interest rate: def fv(pv, rate, n): return round(pv * (1 + rate) ** n, 2) We want to create a partial function from the fv() function that takes only one argument (rate) and computes the annual accumulation factor (n = 1, pv = 1). Select correct answer.

Questions & AnswersCategory: PythonThe following function is given to calculate the future value (fv) of capital (pv) in the n periodic compound capitalization model with the interest rate: def fv(pv, rate, n): return round(pv * (1 + rate) ** n, 2) We want to create a partial function from the fv() function that takes only one argument (rate) and computes the annual accumulation factor (n = 1, pv = 1). Select correct answer.
Geek Boy Staff asked 2 years ago

The following function is given to calculate the future value (fv) of capital (pv) in the n periodic compound capitalization model with the interest rate:

def fv(pv, rate, n):
    return round(pv * (1 + rate) ** n, 2)

We want to create a partial function from the fv() function that takes only one argument (rate) and computes the annual accumulation factor (n = 1, pv = 1). Select correct answer.
a.

annual_acc_factor = fv(pv=1, rate, n=1)

b.

annual_acc_factor = fv(pv=1, rate, n=1)

c.

from functools import partial
annual_acc_factor = partial(fv, pv=1, n=1)
1 Answers
Geek Boy Staff answered 2 years ago

c.

from functools import partial
annual_acc_factor = partial(fv, pv=1, n=1)

Explanation:

functools.partial(func/*args**keywords) – return a new partial object which when called will behave like func called with the positional arguments args and keyword arguments keywords.