githubEdit

Object Oriented Programming

Intro to object-oriented programming concepts in Python.

OOP models real‑world things as objects with data (attributes) and behavior (methods).

Core Ideas

  • Class: blueprint for objects

  • Object: instance of a class

  • Encapsulation: keep data and behavior together

  • Inheritance: reuse behavior from a base class

  • Polymorphism: same interface, different implementations

  • Abstraction: hide complex details behind a simple interface

Quick Example

class Dog:
    def __init__(self, name):
        self.name = name

    def speak(self):
        return f"{self.name} says woof"

pet = Dog("Rex")
print(pet.speak())

Topics

Previous

Last updated