Skip to content

Instantly share code, notes, and snippets.

@Vasanth375
Created January 25, 2023 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vasanth375/53b1749a76dd87bc3cb3a1f922175bd3 to your computer and use it in GitHub Desktop.
Save Vasanth375/53b1749a76dd87bc3cb3a1f922175bd3 to your computer and use it in GitHub Desktop.
class Shape:
def area(self):
pass
class Rectangle(Shape):
def __init__(self, width, height):
self.width = width
self.height = height
def area(self):
return self.width * self.height
class Circle(Shape):
def __init__(self, radius):
self.radius = radius
def area(self):
return 3.14 * self.radius ** 2
shapes = [Rectangle(10, 20), Circle(5)]
for shape in shapes:
print(shape.area())
#Output: 200, 78.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment