
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain briefly the Object oriented concepts in Python?
OOP concepts in Python
Python is an object-oriented programming language. We can easily create and use classes and objects in Python.
Major object-oriented concepts of Python programming language are given below −
Object
Class
Method
Inheritance
Polymorphism
Data Abstraction
Encapsulation
Object
Object is an entity that has state and behaviour. It may be physical and logical. For example: mouse, keyboard, chair, table, pen etc.
Everything in Python is an object, and almost everything has attributes and methods.
Class
Class can be defined as a collection of objects. It is a logical entity that has some specific attributes and methods. For example: if you have a student class then it should contain an attribute and method i.e. an email id, name, age, roll number etc.
Method
Method is a function that is associated with an object. In Python, method is not unique to class instances. Any object type can have methods.
Inheritance
Inheritance specifies that one object acquires all the properties and behaviors of parent object. By using inheritance we can define a new class with a little or no changes to the existing class. The new class is known as derived class or child class and from which it inherits the properties is called base class or parent class. It provides re-usability of the code.
Polymorphism
Polymorphism defines that one task can be performed in different ways. For example: We have a class animal and all animals talk. But they talk differently. Here, the "talk" behaviour totally depends on the animal. So, the abstract "animal" does not actually "talk", but specific animals have a concrete implementation of the action "talk".
Encapsulation
Encapsulation is used to restrict access to methods and variables. In encapsulation, code and data are wrapped together within a single unit from being modified by accident.
Data Abstraction
Data abstraction and encapsulation are synonymous as data abstraction is achieved through encapsulation.
Abstraction is used to hide internal details and show only functionalities. Abstracting something means to give names to things, so that the name captures the basic idea of what a function or a whole program does.
- Related Questions & Answers
- What are basic Object oriented programming concepts?
- Basic Concepts of Object Oriented Programming using C++
- Explain the object oriented data model in DBMS?
- Object Oriented Programming in Python?
- Is Python Object Oriented or Procedural?
- Object-Oriented Databases
- Object-oriented filesystem paths in Python (pathlib)
- Object-oriented Data Model
- What does the repr() function do in Python Object Oriented Programming?
- What does the str() function do in Python Object Oriented Programming?
- What does the cmp() function do in Python Object Oriented Programming?
- Object Oriented language v/s Procedure oriented programming language.
- What is Data Hiding in Python Object Oriented Programming?
- Explain the concepts of Pointers and arrays in C language
- What is overriding in Java can explain briefly with an example?