Python Object-Oriented Programming: Exercises, Solutions, and Practice
This resource offers a total of 55 Python Object-Oriented Programming problems for practice. It includes 11 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
[An Editor is available at the bottom of the page to write and execute the scripts.]
1. Circle Class for Area and Perimeter
Write a Python program to create a class representing a Circle. Include methods to calculate its area and perimeter.
Click me to see the sample solution
2. Person Class with Age Calculation
Write a Python program to create a person class. Include attributes like name, country and date of birth. Implement a method to determine the person's age.
Click me to see the sample solution
3. Calculator Class for Basic Arithmetic Operations
Write a Python program to create a calculator class. Include methods for basic arithmetic operations.
Click me to see the sample solution
4. Shape Class with Subclasses for Different Shapes
Write a Python program to create a class that represents a shape. Include methods to calculate its area and perimeter. Implement subclasses for different shapes like circle, triangle, and square.
Click me to see the sample solution
5. Binary Search Tree Class
Write a Python program to create a class representing a binary search tree. Include methods for inserting and searching for elements in the binary tree.
Click me to see the sample solution
6. Stack Data Structure Class
Write a Python program to create a class representing a stack data structure. Include methods for pushing and popping elements.
Click me to see the sample solution
7. Linked List Data Structure Class
Write a Python program to create a class representing a linked list data structure. Include methods for displaying linked list data, inserting and deleting nodes.
Click me to see the sample solution
8. Shopping Cart Class
Write a Python program to create a class representing a shopping cart. Include methods for adding and removing items, and calculating the total price.
Click me to see the sample solution
9. Stack Data Structure Class with Display Method
Write a Python program to create a class representing a stack data structure. Include methods for pushing, popping and displaying elements.
Click me to see the sample solution
10. Queue Data Structure Class
Write a Python program to create a class representing a queue data structure. Include methods for enqueueing and dequeueing elements.
Click me to see the sample solution
11. Bank Class for Managing Customer Accounts and Transactions
Write a Python program to create a class representing a bank. Include methods for managing customer accounts and transactions.
Click me to see the sample solution
Python Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
Test your Python skills with w3resource's quiz