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 26 of 55 · Python

OOP – Inheritance

Duration: 20 minutes

OOP – Inheritance\n\nInheritance lets you create a subclass that reuses and extends the behavior of a base class.\n\npython\nclass Animal:\n def __init__(self, name):\n self.name = name\n def speak(self):\n raise NotImplementedError\n\nclass Dog(Animal):\n def speak(self):\n return 'Woof!'\n\nclass Cat(Animal):\n def speak(self):\n return 'Meow.'\n\npet = Dog('Rex')\nprint(pet.speak())\n\n\nThe Dog and Cat classes inherit __init__ from Animal and provide their own speak implementation.\n

Previous: OOP Basics – ClassesNext: OOP – Polymorphism