Skip to content

Commit df6d608

Browse files
authored
Merge pull request #43 from Akhileswar6/Feature
updated oops concepts
2 parents 2e48a58 + 3a369ce commit df6d608

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

33_Basic_oops.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Python class -> Classes are blueprints for creating objects. A class defines a set of attributes and methods that the created objects (instances) can have.
1+
"""Python class -> Classes are blueprints for creating objects.
2+
A class defines a set of attributes and methods that the created objects (instances) can have."""
3+
24
class Dog:
35
species = "Canine"
46

34_Encapsulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Encapsulation -> hiding internal details of a class and only exposing what’s necessary.
2-
# It helps to protect important data from being changed directly and keeps the code secure and organized.
1+
"""Encapsulation -> hiding internal details of a class and only exposing what’s necessary.
2+
It helps to protect important data from being changed directly and keeps the code secure and organized."""
33

44
# Example of Encapsulation
55
class Employee:
@@ -56,7 +56,7 @@ def show_salary(self):
5656

5757

5858

59-
# Declaring Protected and private methods
59+
"""Declaring Protected and private methods"""
6060
# 1. Use a single underscore (_) before a method name to indicate it is protected meant to be used within class or its subclasses.
6161
# 2. Use a double underscore (__) to define a private method accessible only within class due to name mangling.
6262
class BankAccount:

35_Inheritance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Inheritance -> It allows a class (child class) to inherit properties and behaviors (attributes and methods) from another class (parent class).
2-
# It promotes code reusability and establishes a hierarchical relationship between classes.
1+
"""Inheritance -> It allows a class (child class) to inherit properties and behaviors (attributes and methods) from another class (parent class).
2+
It promotes code reusability and establishes a hierarchical relationship between classes."""
33

44
class Animal:
55
def __init__(self, name):

36_Polymorphism.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Polymorphism -> "many forms"
2-
# Polymorphism allows same method, function or operator to behave differently depending on object it is working with.
1+
"""Polymorphism -> "many forms"
2+
Polymorphism allows same method, function or operator to behave differently depending on object it is working with."""
33

44
# Types of Polymorphism (Overloading)
55
# 1. Compile-time Polymorphism -> Compile-time polymorphism means deciding which method or operation to run during compilation, usually through method or operator overloading.

37_Data_abstraction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# 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.
1+
"""Data Abstraction -> Python abstraction is used to hide the implementation details from the user and expose only necessary parts,
2+
making the code simpler and easier to interact with."""
23

34
# Abstract Base class
45
from abc import ABC, abstractmethod

38_Iterators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Iterators in Python
2-
# 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.
1+
"""Iterators in Python
2+
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."""
33

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

0 commit comments

Comments
 (0)