Classes and Methods
Inheritence
from math import pi
class LawnShape:
def area(self):
raise Exception("not implemented")
def cost(self, grassPrice):
return self.area() * grassPrice
class Circle(LawnShape):
def __init__(self, radius, cost):
self.radius = radius
def area(self):
return pi * pow(self.radius, 2)
Example: