Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 27 of 55 · Python

OOP – Polymorphism

Duration: 20 minutes

OOP – Polymorphism\n\nPolymorphism means “many forms”. Different classes can be used interchangeably if they implement the same interface or method signature.\n\npython\nclass Shape:\n def area(self):\n raise NotImplementedError\n\nclass Square(Shape):\n def __init__(self, side):\n self.side = side\n def area(self):\n return self.side * self.side\n\nclass Circle(Shape):\n def __init__(self, radius):\n self.radius = radius\n def area(self):\n import math\n return math.pi * self.radius ** 2\n\nshapes = [Square(3), Circle(2)]\nfor s in shapes:\n print('Area:', s.area())\n\n\nBoth Square and Circle implement area(), allowing the loop to treat them uniformly.\n

Previous: OOP – InheritanceNext: OOP – Encapsulation