Python OOP Exercise Questions Last Updated : 22 Sep, 2025 Comments Improve Suggest changes Like Article Like Report This collection of Python OOPs coding practice problems covers everything from defining classes and objects to solving advanced challenges like implementing design patterns and creating custom data structures. Perfect for beginners and seasoned programmers looking to deepen their understanding of OOP in Python!Example ProgramsExercise 1: Create a class Greeter with a method greet(name) that prints a greeting for the provided name. Python class Greeter: def greet(self, name): print(f"Hello, {name}!") # Example usage: g = Greeter() g.greet("Gabriel") OutputHello, Gabriel! Exercise 2: Develop a class Calculator with methods to add and subtract two numbers. Python class Calculator: def add(self, a, b): return a + b def subtract(self, a, b): return a - b # Testing the calculator calc = Calculator() print("Sum:", calc.add(5, 3)) print("Difference:", calc.subtract(5, 3)) OutputSum: 8 Difference: 2 Exercise 3: Build a class Employee with multiple constructors that can initialize an employee object in different ways. Python class Employee: def __init__(self, name, id=None, department=None): self.name = name self.id = id self.department = department def display_details(self): print(f"Name: {self.name}") if self.id: print(f"ID: {self.id}") if self.department: print(f"Department: {self.department}") # Examples emp1 = Employee("John") emp1.display_details() emp2 = Employee("Doe", 101) emp2.display_details() emp3 = Employee("Jane", 102, "HR") emp3.display_details() OutputName: John Name: Doe ID: 101 Name: Jane ID: 102 Department: HR Exercise 4: Design a class SeriesCalculator that calculates the sum of an arithmetic series. Python class SeriesCalculator: def calculate_sum(self, n, a=1, d=2): # Sum of the first n terms of an arithmetic series return n * (2 * a + (n - 1) * d) // 2 # Test the calculator sc = SeriesCalculator() print("Sum of series:", sc.calculate_sum(5)) OutputSum of series: 25 Exercise 5: Create a class MaxFinder that identifies the largest number in a list. Python class MaxFinder: def __init__(self, numbers): self.numbers = numbers def find_max(self): if not self.numbers: return "List is empty" return max(self.numbers) # Example finder = MaxFinder([1, 3, 2, 5, 4]) print("The largest number is:", finder.find_max()) OutputThe largest number is: 5 Practice ProblemsDesign a classConstructorEncapsulationAbstraction Static Method Inheritance Multiple inheritence Method Overriding Operator OverloadingQuizOOPs Comment More info A anuragtriarna Follow Improve Article Tags : Python Python Programs Web Technologies Python Oops-programs Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 7 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like