Jan-20-2022, 06:34 PM
(This post was last modified: Jan-20-2022, 07:07 PM by deanhystad.)
Actually you are doing 10 * 3.14* 3.14 and the answer should be 98.596.
This is bad code. What does it do? area? area of what? By looking at the code I can see that this is the area of a circle with radius x, but I should not have to read the code. And why is y a variable? If this computes the area of a circle is y ever going to be something other than PI?
This is bad code. What does it do? area? area of what? By looking at the code I can see that this is the area of a circle with radius x, but I should not have to read the code. And why is y a variable? If this computes the area of a circle is y ever going to be something other than PI?
def circle_area(radius): """Returns area of circle with radius 'radius'""" return 3.14 * radius * radiusWhat is 3.14? It is kind of close to PI. If it is supposed to be PI, why not use PI?
import math def circle_area(radius): """Returns area of circle with radius 'radius'""" return math.pi * radius**2