Category: Python

3 Python finally

1. What is finally in Python? finally is a block used with try-except. In simple words: 👉 Code inside finally always runs👉 It runs whether an error happens or not👉 It is used for...

4 Python Custom exceptions

1. What is a Custom Exception? A custom exception is an error that you create yourself. In simple words: 👉 Python has many built-in errors👉 Sometimes we need our own error message👉 Custom exceptions...

Python OOP Basics

1. What is OOP? OOP means Object-Oriented Programming. In simple words: 👉 OOP is a way to write programs using objects👉 Objects are made from classes👉 It helps keep code clean, organized, and reusable...

Python Class & object

1. What is a Class? A class is a blueprint or template. In simple words: 👉 A class describes what an object will have and do👉 It does not create a real thing👉 It...

Python Constructor (init)

1. What is a Constructor? A constructor is a special function in a class. In Python, the constructor is called __init__(). In simple words: 👉 __init__() runs automatically👉 It runs when an object is...

Python Instance variables

1. What is an Instance Variable? An instance variable is a variable that belongs to one object only. In simple words: 👉 Each object has its own data👉 One object’s value does not affect...

Python OOP Concepts

1. What are OOP Concepts? OOP means Object-Oriented Programming. In simple words: 👉 OOP is a way to write programs using classes and objects👉 It helps make code clean, reusable, and easy to manage...

Python Inheritance

1. What is Inheritance? Inheritance means one class gets features from another class. In simple words: 👉 A new class uses code of an existing class👉 It saves time👉 It avoids writing the same...

Python Polymorphism

1. What is Polymorphism? Polymorphism means many forms. In simple words: 👉 Same method name👉 Different behavior👉 Works with different objects 2. Real-Life Example Think about the word “run” 🏃 A person runs A...

Python Encapsulation

1. What is Encapsulation? Encapsulation means keeping data safe inside a class. In simple words: 👉 Data and methods are wrapped together👉 Outside code cannot directly change important data👉 We control how data is...