# Import the library here! import math def area_of_circle(radius): return math.pi * radius * radius
Area of Circle
Time for the
math library. It has a lot of mathematical methods and numbers. Surprised?
Suppose you wanted to calculate the area of a circle with more precision and you didn't have pi memorized to 100 digits like most people do. You could either start learning about pi... or just use the
Okay... time to make that hypothetical area of a circle program less hypothetical.
Create a function
area_of_circle that receives the
radius and returns the area of the circle (pi * r * r) using the
math library to get your value for pi.
area_of_circle(1) # 3.141592653589793 area_of_circle(2) # 12.566370614359172