diff --git a/33_Basic_oops.py b/33_Basic_oops.py index b938474..0472b9f 100644 --- a/33_Basic_oops.py +++ b/33_Basic_oops.py @@ -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" diff --git a/34_Encapsulation.py b/34_Encapsulation.py index df279ab..654a14f 100644 --- a/34_Encapsulation.py +++ b/34_Encapsulation.py @@ -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: @@ -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: diff --git a/35_Inheritance.py b/35_Inheritance.py index 0f1dd06..95f3a3b 100644 --- a/35_Inheritance.py +++ b/35_Inheritance.py @@ -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): diff --git a/36_Polymorphism.py b/36_Polymorphism.py index 4a375f9..cea0807 100644 --- a/36_Polymorphism.py +++ b/36_Polymorphism.py @@ -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. diff --git a/37_Data_abstraction.py b/37_Data_abstraction.py index db5ad36..a1018ce 100644 --- a/37_Data_abstraction.py +++ b/37_Data_abstraction.py @@ -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 diff --git a/38_Iterators.py b/38_Iterators.py index 0531205..e2af8b9 100644 --- a/38_Iterators.py +++ b/38_Iterators.py @@ -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.