Rachel M.

asked • 01/25/23

Python function help

I have to write this same basic function six different times, changing the formula in the function each time. I need help getting the first function right.

we have a prompt like this for each of the functions we have to make: sp_comp_annual(present, interest, num_periods) - This function implements the formula for the Single Payment Compound Annual Factor. The three parameters correspond to the variables P, i, and n on the right side of the mathematical formula. The function will return the result of the computation, i.e., the value of F.

the formula for the current function is Compound Annual Factor F= P(1+i)^n


this is my current function

def sp_comp_annual(present, interest, num_periods):

  present,

  interest,

  num_periods,

  return present(1+interest)**num_periods


present = int(input("What is your present value of the money?:" ))

interest = float(input("What is your current interest?:" ))

num_periods = int(input("What is the number of interest periods?:" ))

F = sp_comp_annual(present,

interest,

num_periods,)

print(f"Compound Annual Factor: {F}")


1 Expert Answer

By:

Bradley T. answered • 01/25/23

Tutor
5 (4)

Tutor for Python and High School and Middle School Math

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.