Python Notes5
Python Notes5
geeksforgeeks
Courses
Tutorials
Practice
Contests
Sign In
Python Course
Python Tutorial
Interview Questions
Python Quiz
Python Glossary
Python Projects
Practice Python
Data Science With Python
Python Web Dev
DSA with Python
Python OOPs
As stated earlier, OOP is a programming paradigm that uses objects and classes and
aims to implement real-world entities in programming. The main concepts of OOP are
stated below:
1. Inheritance: It is the process in which one class inherits the methods and
attributes from another class. The class whose properties and methods are inherited
is known as the Parent class and the class which inherits from the parent class is
called the Child class. Inheritance is the most important aspect of object-oriented
programming and provides the reusability of the code.
3. Polymorphism: Polymorphism is taken from the Greek words Poly and morph which
means many and shape respectively. Hence in OOP, Polymorphism refers to the
functions having the same names but having different functionalities. Polymorphism
helps in making programming more intuitive and easier.
Static means that the member is bound to a class level rather than to an instance
level. A static method can not access or modify the state of the class. By using
static, the method doesn't need access to the class instance. Also, using static
methods improves code readability and saves a lot of memory.
4. Deciding Between Internal and Private Modifiers
Developers are used to writing comments in the code but comments do not always
provide the most structured way of workflows. For this inconvenience, Python
structured documentation or docstrings provide a convenient way of associating
documentation with Python public modules, functions, classes, methods, etc. Unlike
source code comments, the docstring describes what the function does and not how.
Docstrings in python are declared using '''triple single quotes''' or """triple
double quotes""".
6. pep8 Guidelines
Python Enterprise Proposal also called PEP are coding conventions for python
packages. Besides writing a code with proper logic, many other important factors
affect a code's quality. PEP 8 is a document that was written in 2001 by Guido van
Rossum, Barry Warsaw, and Nick Coghlan with its main aim to enhance the readability
and consistency of code. One should keep in mind three important pep8 guidelines
that are, to ensure that each line of code is limited to 80 characters, all
libraries should be imported at the beginning, and to eliminate redundant variables
or intermediary variables present in the code.
7. Setting Access to Attributes
Attributes of a class are function objects that are used to implement access
controls of the classes and define corresponding methods of its instances. To
access and manipulate the attributes of a class, python has some in-built methods.
Those are getattr(), hasattr(), setattr() and delattr(). The getattr() function
helps in accessing the attribute of the object. The hasattr() function is used in
checking if an attribute exists or not. Setattr() is used to set an attribute. In
case the attribute does not exist, then one would be created, whereas, delattr() is
used to delete an attribute.
8. Using Abstract Classes
Similar Reads
R - Object Oriented Programming
In this article, we will discuss Object-Oriented Programming (OOPs) in R
Programming Language. We will discuss the S3 and S4 classes, the inheritance in
these classes, and...
15+ min read
Top 10 Object-Oriented Programming Languages in 2024
In the present world, almost all sectors make use of software applications or
computer programs that require to be coded. Programming Language is a set of
instructions use...
15+ min read
A Step-by-Step Approach to Learn Object Oriented Programming
Object-Oriented Programming or OOP's refers to the language that uses objects in
programming. It is primarily concerned with the implementation of real-world
entities such...
15+ min read
Last Minute Notes (LMNs) - Python Programming
Python is a widely-used programming language, celebrated for its simplicity,
comprehensive features, and extensive library support. This "Last Minute Notes"
article aims t...
15+ min read
Metaprogramming with Metaclasses in Python
Metaprogramming in Python lets us write code that can modify or generate other code
at runtime. One of the key tools for achieving this is metaclasses, which allow us
to c...
15+ min read
How to Create a Programming Language using Python?
In this article, we are going to learn how to create your own programming language
using SLY(Sly Lex Yacc) and Python. Before we dig deeper into this topic, it is to
be no...
15+ min read
Programming Paradigms in Python
Paradigm can also be termed as a method to solve some problems or do some tasks. A
programming paradigm is an approach to solve the problem using some programming
language...
15+ min read
Print Objects of a Class in Python
In object-oriented programming (OOP), an object is an instance of a class. A class
serves as a blueprint, defining the structure and behavior of objects, while an
instance...
15+ min read
10 Best Beginner's Tips for Learning Python
Python is a high-level, interpreted, general-purpose programming language that
supports both object-oriented programming and structured programming. It is quite
versatile...
15+ min read
Getting Started with Competitive Programming in Python
Python is a great option for programming in Competitive Programming. First off, its
easy-to-understand and concise grammar enables quicker development and simpler
debuggin...
15+ min read
course-img
53k+ interested Geeks
Complete Data Analytics Program
course-img
89k+ interested Geeks
DSA for Interview Preparation
course-img
278k+ interested Geeks
Python Full Course Online - Complete Beginner to Advanced
course-img
2k+ interested Geeks
Complete Python Program - Mastering from Fundamentals to Advanced Concepts
course-img
330k+ interested Geeks
Data Structures & Algorithms in Python - Self Paced
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh
(201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar,
Uttar Pradesh, 201305
GFG App on Play Store
GFG App on App Store
Advertise with us
Company
About Us
Legal
Privacy Policy
Careers
In Media
Contact Us
GfG Corporate Solution
Placement Training Program
Explore
Job-A-Thon Hiring Challenge
GfG Weekly Contest
Offline Classroom Program
DSA in JAVA/C++
Master System Design
Master CP
GeeksforGeeks Videos
Languages
Python
Java
C++
PHP
GoLang
SQL
R Language
Android Tutorial
DSA
Data Structures
Algorithms
DSA for Beginners
Basic DSA Problems
DSA Roadmap
DSA Interview Questions
Competitive Programming
Web Technologies
HTML
CSS
JavaScript
TypeScript
ReactJS
NextJS
NodeJs
Bootstrap
Tailwind CSS
Python Tutorial
Python Programming Examples
Django Tutorial
Python Projects
Python Tkinter
Web Scraping
OpenCV Tutorial
Python Interview Question
Computer Science
GATE CS Notes
Operating Systems
Computer Network
Database Management System
Software Engineering
Digital Logic Design
Engineering Maths
DevOps
Git
AWS
Docker
Kubernetes
Azure
GCP
DevOps Roadmap
System Design
High Level Design
Low Level Design
UML Diagrams
Interview Guide
Design Patterns
OOAD
System Design Bootcamp
Interview Questions
School Subjects
Mathematics
Physics
Chemistry
Biology
Social Science
English Grammar
Databases
SQL
MYSQL
PostgreSQL
PL/SQL
MongoDB
Preparation Corner
Company-Wise Recruitment Process
Aptitude Preparation
Puzzles
Company-Wise Preparation
More Tutorials
Software Development
Software Testing
Product Management
Project Management
Linux
Excel
All Cheat Sheets
Programming Languages
C Programming with Data Structures
C++ Programming Course
Java Programming Course
Python Full Course
Clouds/Devops
DevOps Engineering
AWS Solutions Architect Certification
Salesforce Certified Administrator Course
GATE 2026
GATE CS Rank Booster
GATE DA Rank Booster
GATE CS & IT Course - 2026
GATE DA Course 2026
GATE Rank Predictor