5.3 step 16 -Shape and Size


did not actually understand what is the question. So we have defined a function in the previous section as follows
def calculate_diameter(circumference):
** pi = 3.14**
** diameter = circumference/pi**
** return diameter**

user_input = int(input (“what is the circumference?”))

this worked perfectly!!.

But in question 16 asked to get the same function and remove the last two lines, but define a function to get the area using radius. So I rewrote the new function as

def find_area(radius):
** pi = 3.14**
** area = pi * radius * radius**
** return area**

but now what should we do? What is the question? As soon as I hit the run code two lines below with 5 and 78.5 appears . then I hit the submitt button…


what I am doing wrong?? and what is the question?

The same code is running well in Jypyter notebook.



I just tried your code. There is definitely a glitch in Stepik. If you have an ability to report it, you should. (I am not logged in there, so I don’t see an option for that).

With that said, let’s find a workaround. I can suggest two approaches:

  1. In formulas, what do we use to group operations, to improve readability and remove possible ambiguity?

  2. Or, alternatively, seeing how you multiply a number by itself, what other math operation can you use in your formula instead? :wink:


Finally it worked…There is nothing wring with the code.

I just tweeted and it worked!!

I changed the area formula to “area = radius * radius * pi” instead of “area = pi * radius * radius”


This doesn’t look right. You probably meant pi instead of the 2 in your formulas. Essentially, you must’ve rearranged the multipliers, right?

The two options I was suggesting above were to group the two radius multipliers with parentheses or to replace the radius * radius multiplication by squaring it.

This is a precision error. You can replicate it by running the different arrangements of the formula on repl.it using a floating point radius and displaying a large number of digits after the decimal point.



Yes, I tried to write in other ways…but did not work except the way I wrote here.


Anything that prioritizes squaring the radius first should probably work equally well.

I’m wondering if this thread is seen by LaunchCode / Stepik curriculum people. This shouldn’t be happening in a course/test for beginners. No wonder the success rate on that question is only 27%.


The code looks good for the function. Did your input syntax match the function? It may be just a question of putting things a certain way to be graded.


As an exercise, I tried this:

pi = 3.14
radius = 5.08932
print("{:.50f}".format((pi * radius * radius)))
print("{:.50f}".format((radius * radius * pi)))
print("{:.50f}".format(pi * (radius ** 2)))
print("{:.50f}".format(pi * (radius * radius)))

This is calculating the area of a circle four diffrent ways. For the radius, I am using a float (even though the problem instructs to expect an integer). Here is what I am getting:


You will notice that there is a precision discrepancy in the 1st result, starting at the 12th digit after the decimal. Apparently, the testing/grading algorithm for this exercise is too strict. They may have an automated test that uses a float (again, even though the problem instructs to assume an integer input).