Object-Oriented Programming System (OOPs) is one of the most important concepts that everyone in the world who write a computer program must have a basic understanding of it.
Let’s first define what is OOPs?
Object-oriented programing is a programming paradigm based on the concept of objects, which contains data and code.
A new question that will obviously strike our mind that what is objects.
An object is an entity that has a state and behaviour associated with it.
An object can be a real-world entity, integer, array, string etc.
An important concept in oops is class, so let’s understand what is class.
A class is a blueprint that contains methods and variables that are common to all kind.
An example to understand it better,
Let Car be a class then Audi and Maruti are the objects of the class Car. All cars have common features such as a steering wheel, four wheels etc.
A simple class code:
## A simple example of class
## A sample method
obj = Test()
A couple of key questions,
What is the difference between the methods and functions?
A method is similar to the function which executes the given instructions to perform a particular task. The only difference between the method and object is that method is associated with objects while functions are not.
What is self?
The self parameter is the reference to the current instance of the class. This is similar to pointers and this in C++ and Java respectively. There must be a self parameter associated with the method of the class for which we don’t give the value, python provides it.
There are three types of access modifiers which we generally use,
Also, there are three types of methods that can be defined in the class,
#python #programming #class #object-oriented #objects #oops python
In this tutorial, we'll learn OOPs Python. Object-Oriented Programming System (OOPs) is one of the most important concepts that everyone in the world who write a computer program…