Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login

Start interactive tutorial

← Back to Exercises

    Python

  • object-oriented-programing

  • oop

  • programacion-orientada-a-objetos

  • poo

Learn Object Oriented Programming with Python

Learn Object Oriented Programming concepts using Python, from basic to advanced topics. This tutorial covers classes, inheritance, polymorphism, encapsulation, and more. Ideal for beginners and experienced developers looking to deepen their understanding.

Work on real-life coding environments with LearnPack.

Get instant help with our AI mentor: Rigobot.

No installation, you go directly to programming

Difficulty

  • easy

Average duration

6 hrs

Difficulty

  • easy

Average duration

6 hrs

Sign up and get access to this free interactive tutorial

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

6 hrs

Difficulty

  • easy

Average duration

6 hrs

Difficulty

  • easy

Average duration

6 hrs

Difficulty

  • easy

Average duration

6 hrs

Learn Python Object-Oriented Programming 🐍

Welcome to this interactive tutorial where you'll learn Object-Oriented Programming (OOP) in Python! We've designed this course to be fun, practical, and easy to follow - even if you're new to programming concepts.

🎯 What will you learn?

By completing this tutorial, you'll understand:

  • How to create and use classes in Python
  • How to work with attributes and methods
  • How inheritance helps you write better code
  • How to protect your data with encapsulation
  • How to make flexible code with polymorphism

And the best part? You'll learn all this by building real, practical examples like:

  • A bank account system
  • A library management system
  • A smart temperature converter
  • A shape calculator
  • A media player system
  • A data processing system

ℹ️ About this tutorial

  • Difficulty: Easy
  • Duration: 6 hours
  • Video Solutions: No
  • Graded: Yes
  • Preview available at: Tutorial Preview

Found a bug? Report it here

📦 Installation

Using LearnPack

  1. First, make sure you have LearnPack CLI installed:
1$ npm install @learnpack/learnpack -g
  1. Clone this repository:
1$ git clone https://github.com/4GeeksAcademy/python-oop-tutorial 2$ cd python-oop-tutorial
  1. Start the tutorial:
1$ learnpack start

Requirements

  • Node.js (v12 or higher)
  • Python (3.7 or higher)
  • NPM (6 or higher)
  • Git

🎓 Prerequisites

  • Basic Python knowledge (variables, functions, loops)
  • A curious mind and willingness to learn!

📚 Course Structure

This tutorial is divided into 5 main sections:

  1. Basic Class Creation (01.0)

    • Your first Python class
    • Understanding class basics
    • Working with simple objects
  2. Attributes and Methods (02.0)

    • Working with class and instance attributes
    • Creating useful methods
    • Understanding how objects store data
  3. Inheritance (03.0)

    • Basic inheritance
    • Multiple inheritance
    • Creating class families
    • Extending functionality
  4. Encapsulation (04.0)

    • Private attributes
    • Property decorators
    • Protected attributes
    • Data protection strategies
  5. Polymorphism (05.0)

    • Method overriding
    • Abstract classes
    • Duck typing
    • Making flexible code

Each section builds on the previous ones, so it's best to follow them in order!

💡 How It Works

Each exercise includes:

  • Clear instructions in everyday language
  • Real-world examples that make sense
  • Step-by-step guidance
  • Working code solutions to check your work
  • Fun challenges to test your understanding

🚀 Getting Started

  1. Open your terminal
  2. Follow the installation steps above
  3. Start with the first exercise in exercises/01.0-introduction-to-oop
  4. Read the instructions in each exercise's README.md
  5. Write your code in the app.py files
  6. Run learnpack test to check your solution
  7. Move on to the next exercise when you're ready!

🎓 Learning Tips

  1. Take Your Time: Don't rush! Each concept builds on the previous ones
  2. Practice Makes Perfect: Try writing your own examples
  3. Experiment: Change the code and see what happens
  4. Use the Examples: Look at the example code carefully
  5. Make Mistakes: It's okay to make mistakes - that's how we learn!
  6. Ask Questions: If you're stuck, ask for help
  7. Review: Go back to previous exercises if needed

🔍 Exercise Format

Each exercise has:

  1. README.md: Explains the concept in simple terms
  2. app.py: Where you write your code
  3. test.py: Checks if your code works
  4. solution.hide.py: Shows you the answer if you need it

💪 Practice Projects

Throughout the tutorial, you'll build:

  1. Person Class: Learn the basics of classes
  2. Student System: Work with attributes and methods
  3. Animal Kingdom: Understand inheritance
  4. Bank Account: Practice encapsulation
  5. Shape Calculator: Master polymorphism

🤝 Need Help?

If you get stuck:

  1. Read the exercise README again
  2. Look at the hints provided
  3. Try the examples
  4. Check the solution file
  5. Ask for help in the community

Remember: Making mistakes is part of learning!

🎉 What's Next After This Course?

After completing this tutorial, you'll be ready to:

  • Write clean, organized Python code
  • Create your own class-based projects
  • Understand OOP code in other projects
  • Apply OOP principles in real-world programming
  • Build more complex applications

📝 Contributing

If you find a bug or want to contribute to this tutorial:

  1. Fork this repository
  2. Create a new branch for your changes
  3. Submit a pull request with your improvements

📄 License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Ready to start your OOP journey? Let's begin with the first exercise! 🚀

Sign up and get access to this free interactive tutorial

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

6 hrs

Difficulty

  • easy

Average duration

6 hrs