I'm stuck in section 5.3

I’m having a hard time figuring out the function thing. I can solve the problem with the function with just math operations.

One way to think of a function is-- it sets things up to do the same operations, with whatever variables it is given. For example, to make a function for “squaring” a variable, you might multiply it by itself. A square function could take any variable and times it by itself, then sending the answer back.

Functions can be especially helpful if a particular set of operations, a particular block of code, has to be used again and again in a program.

Even though there may be easier ways to solve a problem, learning to use functions will really help later on, as programs become larger and broader in scope.


Can you be a little more specific?

Maybe I’m a little nervous, because the deadline for me to complete this is tomorrow I’m down to 68/70 and I am missing something about getting the functions to work. I can solve the problem without using functions, however that’s not what the problem is asking. I’m stuck on the the calculate fill in the blank step in 5.3 and the last one on the find(area) for the circle.

I’m not sure what I’m doing wrong, this is what I have, Ithis is what I have
def calculate_diameter(circumference):
return diameter

TODO: get the circumference from the user

circumference = int (input("Would you type the circumference here: "))

TODO: call the calculate_diameter function with the user’s input and print its result


and I’m getting this error:
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux

Would you type the circumference here: 10
<function calculate_diameter at 0x7fcaeb58ebf8>

1 Like

Hi! The tricky part is that it’s looking for unusual wording. Code looked good & I too had the math right…it wasn’t until I read the board here that I figured it out.
Look down in the other threads…big hints are there. :wink:
Good luck!!

Thanks for the encouragement!

1 Like

In the fill in the box problem, look at line 5. Notice their wording. I like these kinds of problems because when I get stuck, I can work it from the bottom up.
Line 6 is kind of tricky with the wording. :wink:

Also, look back at part where they tell us what result to expect:
"Use 3.14 as the value of pi. If your code works, when the user enters a value of 22, the next line printed to the terminal should be 7.006369426751592"

Test it like you are the user inputting “22” and see what it returns. :muscle:

Your suggestion was very helpful,
I figured out how to solve the find_area problem and got it working in the shell, so I can send the code for that one.
I also got the code running for the calculate_diameter problem in the shell and got the answer that they are looking for like you noted.

However, I’m still stuck getting the right thing for fill in the blank part of it on the next page.

Your code looks good.

Now check out line 6…then look up at line 5. Take it from the top and step through all the lines…when you get to the bottom, you may have to grab scratch paper and stub out your logic. I did anyway. This problem was a bear. lol! Worst one in the whole course (for me).

btw, if you get the coding in the previous page correct, then you’ll be able to plug in the correct answers. That’s how I finally “got” the 6th line correct.

I know it’s frustrating…I finally got it to work on the previous page…now I’m stuck on the fill_in the blank part…makes no sense!
I officially just submitted the the last problem area of the circle.
So, I’m down to this last problem to complete the course.

I’m going to clear my browsing history/cache and log back in…see if that helps…maybe it’s my browser.

Thanks a bunch

Fill-in-the-blank tip: on the last blank try printing the diameter by entering the function with the user input parameter

1 Like

Sadly, it’s not my browser.
I’m enterring
calculate_diameter(int) on the last line

You’re so close! Replace int with the variable given for the user’s input and you’ll have it!

1 Like

They are not calling it “int”

1 Like

Thank you all for your support…I could not have nailed it without you!




YAY! So happy for you! Sleep well tonight! :sleeping:

1 Like

I’m still having trouble figuring out section 5.3 step 11. Please help!

The main point is to set up the function, so that it calculates the diameter from the circumference. What formula can be used, as variables, to achieve this? What should the function “return”-- ie, what output are we expecting?

Further, when a person provides input, do we remember what form that is in? If it is not an integer, will we need to convert it, in order to use it in a function?

Finally, do we know the syntax to “call” a function-- ie what to ask for, concerning what variable(s)?