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

OOP Basics – Classes

Duration: 20 minutes

OOP Basics – Classes\n\nObject‑oriented programming groups data (attributes) and behavior (methods) into classes. Instances of a class are called objects.\n\npython\nclass Person:\n def __init__(self, name, age):\n self.name = name\n self.age = age\n\n def greet(self):\n return f'Hi, I\'m {self.name} and I\'m {self.age} years old.'\n\nbob = Person('Bob', 28)\nprint(bob.greet())\n\n\nThe __init__ method is the constructor; it runs automatically when you create a new object.\n

Previous: Regular ExpressionsNext: OOP – Inheritance