programming-examples/python/Class/Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle.py
2019-11-15 12:59:38 +01:00

13 lines
298 B
Python

class Circle():
def __init__(self, r):
self.radius = r
def area(self):
return self.radius**2*3.14
def perimeter(self):
return 2*self.radius*3.14
NewCircle = Circle(8)
print(NewCircle.area())
print(NewCircle.perimeter())