Question: Exercise: Get Circumference Method Description In this exercise, you will add to your circle class a method to calculate the circumference of a circle instance.


Exercise: Get Circumference Method Description In this exercise, you will add to your circle class a method to calculate the circumference of a circle instance. If you don't know the formula, find it. Use an approximation for pi that has at least 7 digits. Class Name Circle Method getcircumference () Parameters self: the circle object to use Action Calculates the circumference of the circle and returns it. Return Value A number, the circumference of the circle. Examples c = Circle (0.5) c.getcircumference () -> 3.1415926535... Hints Remember, you're adding to the code from the previous step. math.pi from the math module has a reasonable approximation of Pi. import math class Circle: def __init__(self, r): self.radius = r. def getRadius(self): return self.radius def getArea(self): area = self.radius*self.radius*math.pi return area = def setRadius(self, radius): if radius >= 0: self.radius = radius return True else: return false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
