Object Oriented Programming (OOP) in Python
Let’s discuss Object-oriented programming (OOP).
As the name implies, OOP considers tasks performed as objects rather than procedural code in which the computer does steps 1, 2, and so on.
The main advantage of using OOP is that every object is like a small function with its code and structure, which allows it to have its own methods and attributes.
In python language the concept of OOP is structured in the following way:
a . Class,
b. Object,
c. Method,
d. Inheritance,
e. Polymorphism
Let’s discuss these topics one by one.
Class:
A class is a user-defined blueprint of the object to be built. It contains all the attributes and methods of the object.
For example, let’s say we want to create a Citizen class.
Now, if we decide that this class should contain attributes like name, age, and country, we can define these attributes inside the class.
The following code defines the Citizen class in python.