Jan-20-2022, 07:11 PM
(This post was last modified: Jan-20-2022, 07:11 PM by deanhystad.)
My mistake. Actually it is returning 3.14 * 10 * 10. I mixed up the x and y. That is a pretty good indication that x and y are not good variable names. They got me so confused I forgot how to calculate the area of a circle. And now my humiliation is frozen in time in Michael1's reply for all to see.
This is a better way to write the function in question. x should be renamed radius and y should be the constant pi, not a function argument. The function name should clearly indicate what the function does, and the function should have a docstring.
This is a better way to write the function in question. x should be renamed radius and y should be the constant pi, not a function argument. The function name should clearly indicate what the function does, and the function should have a docstring.
import math def circle_area(radius): """Returns area of circle with radius 'radius' """ return math.pi * radius**2