Module 5.2, step 4


#1

Hello, I was wondering if I could have any help on how this module wanted me to fill in the blank for the function on it in order to calculate the compound interest. I tried just entering “(1 + .04 / 12) ** 12” below the line that reads “def calculate_interest(principal):”. That didn’t work. I tried adding “total_value =” in front of the formula, so it reads “total_value = (1 + .04 / 12) ** 12” and also add to line 8 “(total_value)” so it reads “print(calculate_interest(deposit)(total_value))” hoping it would calculate the input and formula together before printing it. That didn’t work either. I’m still troubleshooting with it and was wondering if anyone out there would be willing to give some feedback. Thank you to anyone who is able to help.

**Edit: Step 4, not step 3.


#2

Your main task seems to be to fill in the calculations for the function part of the code.

For that, you use “total_value” and “deposit” variables and whatever mathematical calculations you think work.

The goal is to allow users to input a deposit value and have that returned as a “total_value”.


#3

Thank you. That helps me.


#4

I’m stuck on this as well, I’ve added
total_value = deposit * (1+.04/12)**12
to line 4, but keep getting “none” as the final output. I know I’m missing something, and I’ve been messing with this for quite some time. I don’t want to move on without being able to solve this. Please help! Thanks.


#5

Remember that you are setting up a function, so you need to have it take arguments in and return values.

i.e.:

def(addtwointegers(x,y)):
return (x + y)

So, if we say, addtwointegers(2,5), we calculate return(5 + 2), or 7-- the number seven is returned by this function.


#6

Help what is wrong with this??? the compound interest module 5.2 step 4

fill in the calculate_interest function below, remember to return the total value of the

account after one annual compounding of interest

def calculate_interest(principal):
total_value = deposit * (1+.04/12)**12

prompt the user for their initial deposit

deposit = float(input(“What amount of money did you deposit? Just enter the number, please.”))

print the result of calculate_interest

print(calculate_interest(deposit)(total_value))


#7

Well, your function for calculating interest takes in a principle. So, when you call the function, that will be what needs to go in the parenthesis. When you call it on the last line, you seem to be giving it 2 arguments, the deposit and total value. Maybe do you need to use parenthesis to divide the line into parts?