Write a program that calculates the area and circumference of a circle given its radius.
import math
class Circle:
def __init__(self, radius):
self.radius = radius
def circumference(self):
return 2 * math.pi * self.radius
def area(self):
return math.pi * (self.radius ** 2)
# Driver code to test the Circle class
radius = 5
circle = Circle(radius)
print("The circumference of the circle is:", circle.circumference())
print("The area of the circle is:", circle.area())
note
To compile and run the program, you can use the following commands:
python3 foo.py