w3resource

Python Object-Oriented Programming: Exercises, Solutions, and Practice

Python OOP [ 11 exercises with solution ]

[An editor is available at the bottom of the page to write and execute the scripts.   Go to the editor]

1. 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. 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. Write a Python program to create a calculator class. Include methods for basic arithmetic operations.
Click me to see the sample solution

4. 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. 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. 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. 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. 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. 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. 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. 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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/oop/index.php