Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 33_Basic_oops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Python class -> Classes are blueprints for creating objects. A class defines a set of attributes and methods that the created objects (instances) can have.
"""Python class -> Classes are blueprints for creating objects.
A class defines a set of attributes and methods that the created objects (instances) can have."""

class Dog:
species = "Canine"

Expand Down
6 changes: 3 additions & 3 deletions 34_Encapsulation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Encapsulation -> hiding internal details of a class and only exposing what’s necessary.
# It helps to protect important data from being changed directly and keeps the code secure and organized.
"""Encapsulation -> hiding internal details of a class and only exposing what’s necessary.
It helps to protect important data from being changed directly and keeps the code secure and organized."""

# Example of Encapsulation
class Employee:
Expand Down Expand Up @@ -56,7 +56,7 @@ def show_salary(self):



# Declaring Protected and private methods
"""Declaring Protected and private methods"""
# 1. Use a single underscore (_) before a method name to indicate it is protected meant to be used within class or its subclasses.
# 2. Use a double underscore (__) to define a private method accessible only within class due to name mangling.
class BankAccount:
Expand Down
4 changes: 2 additions & 2 deletions 35_Inheritance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Inheritance -> It allows a class (child class) to inherit properties and behaviors (attributes and methods) from another class (parent class).
# It promotes code reusability and establishes a hierarchical relationship between classes.
"""Inheritance -> It allows a class (child class) to inherit properties and behaviors (attributes and methods) from another class (parent class).
It promotes code reusability and establishes a hierarchical relationship between classes."""

class Animal:
def __init__(self, name):
Expand Down
4 changes: 2 additions & 2 deletions 36_Polymorphism.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Polymorphism -> "many forms"
# Polymorphism allows same method, function or operator to behave differently depending on object it is working with.
"""Polymorphism -> "many forms"
Polymorphism allows same method, function or operator to behave differently depending on object it is working with."""

# Types of Polymorphism (Overloading)
# 1. Compile-time Polymorphism -> Compile-time polymorphism means deciding which method or operation to run during compilation, usually through method or operator overloading.
Expand Down
3 changes: 2 additions & 1 deletion 37_Data_abstraction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Data Abstraction -> Python abstraction is used to hide the implementation details from the user and expose only necessary parts, making the code simpler and easier to interact with.
"""Data Abstraction -> Python abstraction is used to hide the implementation details from the user and expose only necessary parts,
making the code simpler and easier to interact with."""

# Abstract Base class
from abc import ABC, abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions 38_Iterators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Iterators in Python
# An iterator in Python is an object used to traverse through all the elements of a collection (like lists, tuples or dictionaries) one element at a time.
"""Iterators in Python
An iterator in Python is an object used to traverse through all the elements of a collection (like lists, tuples or dictionaries) one element at a time."""

# __iter__(): Returns the iterator object itself.
# __next__(): Returns the next value from the sequence. Raises StopIteration when the sequence ends.
Expand Down