Module 5.3 - Screeching halt

Hey! I am finished with the course, with the exception of one quiz in unit 5.3 - the one where we’re asked to write some code to calculate the diameter of a circle using its user-provided diameter. I have spent three days trying to power through the problem with zero success. I have written dozens of versions of my code, most of which work in the code editor (and on as expected. I have googled similar problems in python extensively and I have just not been able to figure out exactly what the quiz is expecting to hear. My issue is with the last line of the quiz, the print command wording - the other four fields are pretty cut-and-dried so I won’t spoil the surprise on those. Here is my latest code for the print command line:
print("The diameter of the circle is ", calculate_diameter(circumference), “.”)
I have also tried the following (all of which run correctly, and many other variations):
print(“The diameter is:”, calculate_diameter(circumference))

Anyone have any suggestions for me?
Thanks in advance!

1 Like

Sometimes an error message seems to indicate a problem with, say, a print line-- but the issue is elsewhere (ie maybe the way the function is defined). If the function sends an unacceptable value to the print line, that might generate an error message-- Just my 2 cents. You might try looking back at the function you defined and called and make sure it is tight.

1 Like

Thank you! I will revisit that.

No dice, unfortunately. I have come to the conclusion that it’s time to move on, as this seems to be not a priority in the long run, it’s just a tutorial. I appreciated the rest of it very much and am moving on to other classes in Python + other languages. Thanks for the help!

Hi @Masmics, sorry for the late reply. It looks like you aren’t using the user_input variable defined in the line above when calling your function. That variable will hold the number that was provided as the circumference, so that is the number you want to send to your function. If you simply send circumference to calculate_diameter, the value that the user entered will be lost.

Also, this function only needs to print the diameter - two of your lines above appear to provide extra text ("The diameter of the circle is " and “The diameter is:”). While this would normally be helpful to someone reading the results of your program, that extra text will confuse the quiz in Stepik.

Thanks Adam! I finally got it worked out. I wasn’t getting that user_input could be passed in in place of circumference in the function definition (because user_input is also a variable and because circumference is part of a standard equation, that wasn’t intuitive to me at all, I would have just labeled the user input variable accordingly). I wasn’t going to revisit it because it ended up not being a great use of my time at that moment, but I’m glad I did. Thank you very much!


I still don’t get it because those are drop down menus and you cannot put the user_input in place of the circumference. I am so confused.

I would have just typed:
circumference=float(input(“What is the circumference?”)

I’m lost on this one too. I have the following:
pi = 3.14
def calculate_diameter (circumfrance):
diameter = circumfrance / pi
circumfrance = int(input(“please state the circumfrance”))
print ("The diameter is: ") , calculate_diameter (circumfrance):

That code prints the following:
“The diameter is None”

What’s going on? I’ve tried replacing the last “Circumfrance” with “diameter”, but that produces “None” too. I have no idea what’s going on, and if Adam’s comment already answered this question, I’m really sorry, but I didn’t understand what he meant.

There’s another practice problem shortly after this one and I’m having the same issue.

While I’m at it, can you please state how to “call” a function?

When you define your function, you will do this first, and keep it apart from the rest of the code with some spaces. Also, remember to provide a return from your function, so that when you call it there is a result.


Your code is all in wrong order. Your print statement may not be formatted correctly either (there is a colon at the end, and a parenthesis is in a wrong place). If you fix those issues, perhaps you’ll get to better understanding.

Think of it this way: For your function to work, it needs a circumference. If you are asking the user for the circumference, that request should come BEFORE the function can make a use of it.