The course "Object-oriented programming in Python" + Answers
The course "Object-oriented programming in Python" introduces the features of object-oriented programming in general and its implementation in the Python language. The application is supplemented with examples of practical work solutions. The lessons themselves are freely available at https://younglinux.info/oopython/course. Short video versions of the lessons: https://www.youtube.com/playlist?list=PLx40Tc4pO423OvwMLI7VNwXqoSOnWF_53
The course assumes prior knowledge of structured programming in Python, which you can get acquainted with in our first course "Python. Introduction to Programming": https://younglinux.info/python/course.
The course includes 15 lessons:
1. What is object-oriented programming
2. Creation of classes and objects
3. Class constructor - __init __ () method
4. Inheritance
5. Polymorphism
6. Encapsulation
7. Composition
8. Operator overloading
9. Static methods
10. Iterators
11. Generators
12. Modules and packages
13. Documenting the code
14. Sample Object Oriented Python Program
15. Results of the course "Object-oriented programming in Python"
The key concepts in object-oriented programming are "class" and "object". Objects are derived from their classes. In the Python programming language, such objects are called instances.
Inheritance, polymorphism and encapsulation are the basic principles, pillars of object-oriented programming. Inheritance implies the ability to define child classes, polymorphism is a different way of implementing the same thing, encapsulation is hiding and combining data and methods. Composition is implemented less often, it means the ability to create objects, the constituent parts of which are objects of other classes.
A constructor in OOP is a class method that is called automatically when an object is created from this class. At the same time, constructor refers to operator overloading methods. The names of such methods are regulated by the programming language itself, and their call occurs automatically when the object participates in certain operations. For example, adding, extracting an element, etc.
Iterators are a special kind of objects, similar to collections like a list, but which do not store the entire set of elements, but generate only one each time it is accessed. Python has built-in datatype classes from which iterators are created. However, you can also define your own classes, whose instances will have iterator capabilities.