This document discusses object-oriented programming concepts in Python including:
- Classes define templates for objects with attributes and methods. Objects are instances of classes.
- The __init__ method initializes attributes when an object is constructed.
- Classes can make attributes private using double underscores. Encapsulation hides implementation details.
- Objects can be mutable, allowing state changes, or immutable like strings which cannot change.
- Inheritance allows subclasses to extend and modify parent class behavior through polymorphism.
This document discusses object-oriented programming concepts in Python including classes, objects, attributes, methods, inheritance, polymorphism, and special methods. Key points include:
- Classes are templates that define objects, while objects are instantiations of classes with unique attribute values.
- Methods define object behaviors. The self parameter refers to the current object instance.
- Inheritance allows classes to extend existing classes, reusing attributes and methods from parent classes.
- Special methods with double underscores have predefined meanings (e.g. __init__ for constructors, __repr__ for string representation).
Python is an object-oriented programming language. This means that almost all the code is implemented using a special construct called classes.
Python offers classes, which are a effective tool for writing reusable code. To describe objects with shared characteristics and behaviors, classes are utilized.
This document discusses Python modules, classes, inheritance, and properties. Some key points:
- Modules allow the organization of Python code into reusable libraries by saving code in files with a .py extension. Modules can contain functions, variables, and be imported into other code.
- Classes are templates that define the properties and methods common to all objects of a certain kind. The __init__() method initializes new objects. Inheritance allows child classes to inherit properties and methods from parent classes.
- Properties provide a way to control access to class attributes, allowing them to be accessed like attributes while hiding the implementation details behind getter and setter methods.
The document introduces Python modules and importing. It discusses three formats for importing modules: import somefile, from somefile import *, and from somefile import className. It describes commonly used Python modules like sys, os, and math. It also covers defining your own modules, directories for module files, object-oriented programming in Python including defining classes, creating and deleting instances, methods and self, accessing attributes and methods, attributes, inheritance, and redefining methods.
This document summarizes an upcoming webinar on Python. The webinar will cover object-oriented programming in Python, Numpy, and Pandas. It provides background on procedural programming versus object-oriented programming, describing key concepts of OOP like classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It then goes into detail explaining each of these OOP concepts through examples and definitions.
This document provides an overview of object-oriented programming concepts in Python including objects, classes, inheritance, polymorphism, and encapsulation. It defines key terms like objects, classes, and methods. It explains how to create classes and objects in Python. It also discusses special methods, modules, and the __name__ variable.
The document defines key object-oriented programming concepts like classes, objects, inheritance, polymorphism, encapsulation and abstraction.
It explains that a class is a logical grouping of attributes and methods, an object is an instance of a class, and object instantiation is the process of creating an object. It discusses self parameter, init methods, class attributes, instance attributes, static and instance methods.
It describes inheritance, multiple and multilevel inheritance. It covers abstraction, encapsulation, polymorphism and operator overloading. It also discusses naming conventions, abstract base classes, overriding and the use of super().
Python supports object-oriented programming through classes, objects, and related concepts like inheritance, polymorphism, and encapsulation. A class acts as a blueprint to create object instances. Objects contain data fields and methods. Inheritance allows classes to inherit attributes and behaviors from parent classes. Polymorphism enables the same interface to work with objects of different types. Encapsulation helps protect data by restricting access.
The document discusses various advanced Python concepts including classes, exception handling, generators, CGI, databases, Tkinter for GUI, regular expressions, and email sending using SMTP. It covers object-oriented programming principles like inheritance, encapsulation, and polymorphism in Python. Specific Python concepts like creating and accessing class attributes, instantiating objects, method overloading, operator overloading, and inheritance are explained through examples. The document also discusses generator functions and expressions for creating iterators in Python in a memory efficient way.
The document discusses object-oriented programming concepts in Python like classes, objects, inheritance, polymorphism, and multiple inheritance. It provides examples of defining classes with methods and instantiating objects. Inheritance allows deriving a child class from a parent class to inherit attributes and methods. Methods can be overridden in the child class. Super() is used to explicitly call the parent class's method. Multiple inheritance allows a class to inherit from multiple parent classes.
Python allows importing and using classes and functions defined in other files through modules. There are three main ways to import modules: import somefile imports everything and requires prefixing names with the module name, from somefile import * imports everything without prefixes, and from somefile import className imports a specific class. Modules look for files in directories listed in sys.path.
Classes define custom data types by storing shared data and methods. Instances are created using class() and initialized with __init__. Self refers to the instance inside methods. Attributes store an instance's data while class attributes are shared. Inheritance allows subclasses to extend and redefine parent class features. Special built-in methods control class behaviors like string representation or iteration.
The document discusses object-oriented programming concepts in Python like classes, objects, inheritance and polymorphism.
Some key points:
- Classes define the structure and behavior of an object using methods and attributes.
- Objects are instances of a class that contain data and allow methods to operate on that data.
- Inheritance allows a derived/child class to inherit attributes and methods from a base/parent class. The derived class can override or extend the parent class.
- Polymorphism allows derived classes to define their own implementation of a method while reusing the parent's implementation.
The document discusses key concepts of object-oriented programming such as classes, objects, encapsulation, inheritance, and polymorphism. It provides examples of defining a Point class in Python with methods like translate() and distance() as well as using concepts like constructors, private and protected members, and naming conventions using underscores. The document serves as an introduction to object-oriented programming principles and their implementation in Python.
The document discusses object-oriented programming concepts in Python like classes, objects, methods, variables, inheritance and polymorphism. It provides examples of how to define a class with attributes and methods, create objects, and access variables and call methods. It also explains different types of methods like instance methods, class methods, static methods and variable types like instance and static/class variables. Inheritance allows creating new classes from existing classes for code reusability.
The document discusses object-oriented programming concepts like classes, objects, methods, encapsulation, abstraction, and inheritance. It provides examples of defining classes with attributes and methods, creating objects, and accessing object properties and methods. Constructors (__init__()) are discussed as special methods that initialize objects. Encapsulation, information hiding, and abstraction are presented as key concepts for modeling real-world objects in code with public and private interfaces.
This document discusses object-oriented programming concepts in Python like classes, objects, encapsulation, inheritance and polymorphism. It explains that classes are user-defined blueprints that contain data fields and methods, and objects are instances of classes. The key concepts of OOP like data encapsulation, abstraction, inheritance and polymorphism are explained with examples in Python. Various special methods like __init__(), __str__(), __repr__() and their usage with classes are also covered.
This document discusses object oriented programming concepts like classes, objects, encapsulation, and abstraction. It defines classes as blueprints for objects that can contain methods and attributes. Objects are instances of classes that contain the class's methods and properties. Encapsulation is implemented by making fields private and accessing them via public getter and setter methods to protect data. Abstraction exposes only relevant data in a class interface and hides private attributes and methods.
Problem solving with python programming OOP's Conceptrohitsharma24121
This document discusses object-oriented programming concepts in Python including classes, objects, inheritance, encapsulation, polymorphism and abstraction. It provides examples of defining classes and objects in Python, creating methods, modifying and deleting object properties, inheritance between parent and child classes using the super() function, and using abstraction, encapsulation and polymorphism. Key topics covered include class definitions, the __init__() method, self parameter, inheritance between multiple classes, and polymorphism through method overloading and overriding.
OOPS stands for Object-Oriented Programming System or Object-Oriented Programming Structure. It's a programming paradigm that organizes code into objects that contain data and behavior.
This document summarizes an upcoming webinar on Python. The webinar will cover object-oriented programming in Python, Numpy, and Pandas. It provides background on procedural programming versus object-oriented programming, describing key concepts of OOP like classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It then goes into detail explaining each of these OOP concepts through examples and definitions.
This document provides an overview of object-oriented programming concepts in Python including objects, classes, inheritance, polymorphism, and encapsulation. It defines key terms like objects, classes, and methods. It explains how to create classes and objects in Python. It also discusses special methods, modules, and the __name__ variable.
The document defines key object-oriented programming concepts like classes, objects, inheritance, polymorphism, encapsulation and abstraction.
It explains that a class is a logical grouping of attributes and methods, an object is an instance of a class, and object instantiation is the process of creating an object. It discusses self parameter, init methods, class attributes, instance attributes, static and instance methods.
It describes inheritance, multiple and multilevel inheritance. It covers abstraction, encapsulation, polymorphism and operator overloading. It also discusses naming conventions, abstract base classes, overriding and the use of super().
Python supports object-oriented programming through classes, objects, and related concepts like inheritance, polymorphism, and encapsulation. A class acts as a blueprint to create object instances. Objects contain data fields and methods. Inheritance allows classes to inherit attributes and behaviors from parent classes. Polymorphism enables the same interface to work with objects of different types. Encapsulation helps protect data by restricting access.
The document discusses various advanced Python concepts including classes, exception handling, generators, CGI, databases, Tkinter for GUI, regular expressions, and email sending using SMTP. It covers object-oriented programming principles like inheritance, encapsulation, and polymorphism in Python. Specific Python concepts like creating and accessing class attributes, instantiating objects, method overloading, operator overloading, and inheritance are explained through examples. The document also discusses generator functions and expressions for creating iterators in Python in a memory efficient way.
The document discusses object-oriented programming concepts in Python like classes, objects, inheritance, polymorphism, and multiple inheritance. It provides examples of defining classes with methods and instantiating objects. Inheritance allows deriving a child class from a parent class to inherit attributes and methods. Methods can be overridden in the child class. Super() is used to explicitly call the parent class's method. Multiple inheritance allows a class to inherit from multiple parent classes.
Python allows importing and using classes and functions defined in other files through modules. There are three main ways to import modules: import somefile imports everything and requires prefixing names with the module name, from somefile import * imports everything without prefixes, and from somefile import className imports a specific class. Modules look for files in directories listed in sys.path.
Classes define custom data types by storing shared data and methods. Instances are created using class() and initialized with __init__. Self refers to the instance inside methods. Attributes store an instance's data while class attributes are shared. Inheritance allows subclasses to extend and redefine parent class features. Special built-in methods control class behaviors like string representation or iteration.
The document discusses object-oriented programming concepts in Python like classes, objects, inheritance and polymorphism.
Some key points:
- Classes define the structure and behavior of an object using methods and attributes.
- Objects are instances of a class that contain data and allow methods to operate on that data.
- Inheritance allows a derived/child class to inherit attributes and methods from a base/parent class. The derived class can override or extend the parent class.
- Polymorphism allows derived classes to define their own implementation of a method while reusing the parent's implementation.
The document discusses key concepts of object-oriented programming such as classes, objects, encapsulation, inheritance, and polymorphism. It provides examples of defining a Point class in Python with methods like translate() and distance() as well as using concepts like constructors, private and protected members, and naming conventions using underscores. The document serves as an introduction to object-oriented programming principles and their implementation in Python.
The document discusses object-oriented programming concepts in Python like classes, objects, methods, variables, inheritance and polymorphism. It provides examples of how to define a class with attributes and methods, create objects, and access variables and call methods. It also explains different types of methods like instance methods, class methods, static methods and variable types like instance and static/class variables. Inheritance allows creating new classes from existing classes for code reusability.
The document discusses object-oriented programming concepts like classes, objects, methods, encapsulation, abstraction, and inheritance. It provides examples of defining classes with attributes and methods, creating objects, and accessing object properties and methods. Constructors (__init__()) are discussed as special methods that initialize objects. Encapsulation, information hiding, and abstraction are presented as key concepts for modeling real-world objects in code with public and private interfaces.
This document discusses object-oriented programming concepts in Python like classes, objects, encapsulation, inheritance and polymorphism. It explains that classes are user-defined blueprints that contain data fields and methods, and objects are instances of classes. The key concepts of OOP like data encapsulation, abstraction, inheritance and polymorphism are explained with examples in Python. Various special methods like __init__(), __str__(), __repr__() and their usage with classes are also covered.
This document discusses object oriented programming concepts like classes, objects, encapsulation, and abstraction. It defines classes as blueprints for objects that can contain methods and attributes. Objects are instances of classes that contain the class's methods and properties. Encapsulation is implemented by making fields private and accessing them via public getter and setter methods to protect data. Abstraction exposes only relevant data in a class interface and hides private attributes and methods.
Problem solving with python programming OOP's Conceptrohitsharma24121
This document discusses object-oriented programming concepts in Python including classes, objects, inheritance, encapsulation, polymorphism and abstraction. It provides examples of defining classes and objects in Python, creating methods, modifying and deleting object properties, inheritance between parent and child classes using the super() function, and using abstraction, encapsulation and polymorphism. Key topics covered include class definitions, the __init__() method, self parameter, inheritance between multiple classes, and polymorphism through method overloading and overriding.
OOPS stands for Object-Oriented Programming System or Object-Oriented Programming Structure. It's a programming paradigm that organizes code into objects that contain data and behavior.
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfChalaKelbessa
This is Forestry Exit Exam Model for 2025 from Department of Forestry at Wollega University, Gimbi Campus.
The exam contains forestry courses such as Dendrology, Forest Seed and Nursery Establishment, Plantation Establishment and Management, Silviculture, Forest Mensuration, Forest Biometry, Agroforestry, Biodiversity Conservation, Forest Business, Forest Fore, Forest Protection, Forest Management, Wood Processing and others that are related to Forestry.
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdfTechSoup
In this webinar we will dive into the essentials of generative AI, address key AI concerns, and demonstrate how nonprofits can benefit from using Microsoft’s AI assistant, Copilot, to achieve their goals.
This event series to help nonprofits obtain Copilot skills is made possible by generous support from Microsoft.
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...wygalkelceqg
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical Management 2nd Ed Klotz
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical Management 2nd Ed Klotz
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical Management 2nd Ed Klotz
How to Create a Stage or a Pipeline in Odoo 18 CRMCeline George
In Odoo, the CRM (Customer Relationship Management) module’s pipeline is a visual representation of a company's sales process that helps sales teams track and manage their interactions with potential customers.
IDSP is a disease surveillance program in India that aims to strengthen/maintain decentralized laboratory-based IT enabled disease surveillance systems for epidemic prone diseases to monitor disease trends, and to detect and respond to outbreaks in the early phases swiftly.....
RELATIONS AND FUNCTIONS
1. Cartesian Product of Sets:
If A and B are two non-empty sets, then their Cartesian product is:
A × B = {(a, b) | a ∈ A, b ∈ B}
Number of elements: |A × B| = |A| × |B|
2. Relation:
A relation R from set A to B is a subset of A × B.
Domain: Set of all first elements.
Range: Set of all second elements.
Codomain: Set B.
3. Types of Relations:
Empty Relation: No element in R.
Universal Relation: R = A × A.
Identity Relation: R = {(a, a) | a ∈ A}
Reflexive: (a, a) ∈ R ∀ a ∈ A
Symmetric: (a, b) ∈ R ⇒ (b, a) ∈ R
Transitive: (a, b), (b, c) ∈ R ⇒ (a, c) ∈ R
Equivalence Relation: Reflexive, symmetric, and transitive
4. Function (Mapping):
A relation f: A → B is a function if every element of A has exactly one image in B.
Domain: A, Codomain: B, Range ⊆ B
5. Types of Functions:
One-one (Injective): Different inputs give different outputs.
Onto (Surjective): Every element of codomain is mapped.
One-one Onto (Bijective): Both injective and surjective.
Constant Function: f(x) = c ∀ x ∈ A
Identity Function: f(x) = x
Polynomial Function: e.g., f(x) = x² + 1
Modulus Function: f(x) = |x|
Greatest Integer Function: f(x) = [x]
Signum Function: f(x) =
-1 if x < 0,
0 if x = 0,
1 if x > 0
6. Graphs of Functions:
Learn shapes of basic graphs: modulus, identity, step function, etc.
Order Lepidoptera: Butterflies and Moths.pptxArshad Shaikh
Lepidoptera is an order of insects comprising butterflies and moths. Characterized by scaly wings and a distinct life cycle, Lepidoptera undergo metamorphosis from egg to larva (caterpillar) to pupa (chrysalis or cocoon) and finally to adult. With over 180,000 described species, they exhibit incredible diversity in form, behavior, and habitat, playing vital roles in ecosystems as pollinators, herbivores, and prey. Their striking colors, patterns, and adaptations make them a fascinating group for study and appreciation.
POS Reporting in Odoo 18 - Odoo 18 SlidesCeline George
To view all the available reports in Point of Sale, navigate to Point of Sale > Reporting. In this section, you will find detailed reports such as the Orders Report, Sales Details Report, and Session Report, as shown below.
Introduction to Online CME for Nurse Practitioners.pdfCME4Life
Online CME for nurse practitioners provides a flexible, cost-effective way to stay current with evidence-based practices and earn required credits without interrupting clinical duties. Accredited platforms offer a wide range of self-paced courses—complete with interactive case studies, downloadable resources, and immediate digital certificates—that fit around demanding schedules. By choosing trusted providers, practitioners gain in-depth knowledge on emerging treatments, refine diagnostic and patient-management skills, and build professional credibility. Know more at https://cme4life.com/the-benefits-of-online-cme-for-nurse-practitioners/
Updated About Me. Used for former college assignments.
Make sure to catch our weekly updates. Updates are done Thursday to Fridays or its a holiday/event weekend.
Thanks again, Readers, Guest Students, and Loyalz/teams.
This profile is older. I started at the beginning of my HQ journey online. It was recommended by AI. AI was very selective but fits my ecourse style. I am media flexible depending on the course platform. More information below.
AI Overview:
“LDMMIA Reiki Yoga refers to a specific program of free online workshops focused on integrating Reiki energy healing techniques with yoga practices. These workshops are led by Leslie M. Moore, also known as LDMMIA, and are designed for all levels, from beginners to those seeking to review their practice. The sessions explore various themes like "Matrix," "Alice in Wonderland," and "Goddess," focusing on self-discovery, inner healing, and shifting personal realities.”
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesCeline George
The Lunch module in Odoo 18 helps users place their food orders, making meal management seamless and efficient. It allows employees to browse available options, place orders, and track their meals effortlessly.
Prottutponnomotittwa: A Quiz That Echoed the Pulse of Bengal
On the 31st of May, 2025, PRAGYA – The Official Quiz Club of UEM Kolkata – did not merely organize another quiz. It hosted an ode to Bengal — its people, its quirks, its politics, its art, its rebellion, its heritage. Titled Prottutponnomotittwa, the quiz stood as a metaphor for what Bengal truly is: sharp, intuitive, spontaneous, reflective. A cultural cosmos that thrives on instinct, memory, and emotion.
From the very first slide, it became clear — this wasn’t a quiz made to showcase difficulty or elitism. It was crafted with love — love for Bangla, for its past, present, and its ever-persistent contradictions.
The diversity of the answer list tells the real story of the quiz. The curation was not random. Each answer was a string on a veena of cultural resonance.
In the “Cultural Pairings” round, Anusheh Anadil and Arnob were placed not just as musicians, but as voices of a modern, cross-border Bangla. Their works, which blend baul, jazz, and urban folk, show how Bengal exists simultaneously in Dhaka and Shantiniketan.
The inclusion of Ritwik Chakraborty and Srijit Mukherjee (as a songwriter) showed how the quiz masters understood evolution. Bangla cinema isn’t frozen in the Ray-Ghatak past. It lives, argues, breaks molds — just like these men do.
From Kalyani Black Label to Radhunipagol Chal, consumer culture too had its place. One is liquid courage, the other culinary madness — both deeply Bengali.
The heart truly swelled when the answers touched upon Baidyanath Bhattacharya and Chandril. Both satirists, both sharp, both essential. It was not just about naming them — it was about understanding what different types of literature means in a Bengali context.
Titumir — the play about a peasant rebel who built his own bamboo fort and dared to challenge the British.
Krishnananda Agamvagisha — the mystical Tantric who shaped how we understand esoteric Bengali spiritualism.
Subhas Chandra Bose — the eternal enigma, the braveheart whose shadow looms large over Bengal’s political psyche.
Probashe Ghorkonna — a story lived by many Bengalis. The medinipur daughter, who made a wholesome family, not only in bengal, but across the borders. This answer wasn’t just information. It was emotion.
By the end, what lingered was not the scoreboard. It was a feeling.
The feeling of sitting in a room where Chalchitro meets Chabiwala, where Jamai Shosthi shares the stage with Gayatri Spivak, where Bhupen Hazarika sings with Hemanga Biswas, and where Alimuddin Road and Webskitters occupy the same mental map.
You don’t just remember questions from this quiz.
You remember how it made you feel.
You remember smiling at Keet Keet, nodding at Prabuddha Dasgupta, getting goosebumps at the mention of Bose, and tearing up quietly when someone got Radhunipagol Chal right.
This wasn’t a quiz.
This was an emotional ride of Bangaliyana.
This was — and will remain — Prottutponnomotittwa.
How to Configure Add to Cart in Odoo 18 WebsiteCeline George
In this slide, we’ll discuss how to configure the Add to Cart functionality in the Odoo 18 Website. This feature enhances the shopping experience by offering three flexible options: Stay on the Product Page, Go to the Cart, or Let the User Decide through a dialog box.
Stewart Butler - OECD - How to design and deliver higher technical education ...EduSkills OECD
Stewart Butler, Labour Market Economist at the OECD presents at the webinar 'How to design and deliver higher technical education to develop in-demand skills' on 3 June 2025. You can check out the webinar recording via our website - https://oecdedutoday.com/webinars/ .
You can check out the Higher Technical Education in England report via this link 👉 - https://www.oecd.org/en/publications/higher-technical-education-in-england-united-kingdom_7c00dff7-en.html
You can check out the pathways to professions report here 👉 https://www.oecd.org/en/publications/pathways-to-professions_a81152f4-en.html
Search Engine Optimization (SEO) for Website SuccessMuneeb Rana
Unlock the essentials of Search Engine Optimization (SEO) with this concise, visually driven PowerPoint. Inside you’ll find:
✅ Clear definitions and core concepts of SEO
✅ A breakdown of On‑Page, Off‑Page, and Technical SEO
✅ Actionable best‑practice checklists for keyword research, content optimization, and link building
✅ A quick‑start toolkit featuring Google Analytics, Search Console, Ahrefs, SEMrush, and Moz
✅ Real‑world case study demonstrating a 70 % organic‑traffic lift
✅ Common challenges, algorithm updates, and tips for long‑term success
Whether you’re a digital‑marketing student, small‑business owner, or PR professional, this deck will help you boost visibility, build credibility, and drive sustainable traffic. Download, share, and start optimizing today!
2. Object oriented Concepts: Creating class, Creating object
• Class- Classes are defined by the user. The class provides the
basic structure for an object. It consists of data members and
method members that are used by the instances(object) of the
class.
• Object- A unique instance of a data structure that is defined by
its class. An object comprises both data members and methods.
Class itself does nothing but real functionality is achieved through their
objects.
3. Creating Classes:
• Syntax :-
class ClassName:
#list of python class variables
# Python class constructor
#Python class method definitions
• In a class we can define variables, functions etc. While writing function in class we have to
pass atleast one argument that is called self parameter.
• The self parameter is a reference to the class itself and is used to access variables that
belongs to the class.
4. Example:
Example: Creating class
class student:
def display(self):
print("Hello Python")
In python programming self is a default variable that contains the memory address
of the instance of the current class.
Creating Objects-Objects can be used to access the attributes of the class
s1=student() #creating object of class
s1.display() #calling method of class using object
5. Instance variable and Class variable:
• Instance variable is defined in a method and its scope is only within the object
that defines it
• Class variable is defined in the class and can be used by all the instances of that
class.
• Instance variables are unique for each instance, while class variables are shared
by all instances.
6. Example: For instance and class variables
• class sample:
x=2 # x is class variable
def get(self,y): # y is instance variable
self.y=y
s1=sample()
s1.get(3)
print(s1.x," ",s1.y)
s2=sample()
S2.get(4)
print(s2.x," ",s2.y)
7. Example: Class with get and put method
• class car:
def get(self,color,style):
self.color=color
self.style=style
def put(self):
print(self.color)
print(self.style)
• c=car()
• c.get('Black','Red')
• c.put()
8. Method Overloading
• Method overloading is the ability to define the method with the same
name but with a different number of arguments and data types.
• Python does not support method overloading i.e it is not possible to
define more than one method with the same name in a class in python.
• This is because method arguments in python do not have a type.
9. Method Overloading
# To calculate area of rectangle
• def area(length,breadth):
calc=length*breadth
print(calc)
• # To calculate area of square
• def area(size):
calc=size*size
print(calc)
area(3)
area(4,5)
10. • Output9
Traceback (most recent call last):
File "D:python programstrial.py", line 10, in <module>
area(4,5)
TypeError: area() takes 1 positional argument but 2 were given
11. Data hiding
• Data hiding is a software development technique specifically used in object
oriented programming to hide internal object details(data members).
• Data hiding is also known as information hiding. An objects attributes may
or may not be visible outside the class definition
• In Python, you can achieve data hiding by using a double underscore prefix
(__) before an attribute or method name
• Any variable prefix
• with double underscore is called private variable which is accessible only
• with class where it is declared
12. • class counter:
• __secretcount=0 # private variable
• def count(self): # public method
• self.__secretcount+=1
• print("count= ",self.__secretcount) # accessible in the same class
• c1=counter()
• c1.count() # invoke method
• c1.count()
• print("Total count= ",c1.__secretcount) # cannot access private variable directly
14. Data abstraction
• Data abstraction refers to providing only essential information about the data to
the outside world, hiding the background details of implementation.
• In short hiding internal details and showing functionality is known as abstraction.
• Access modifiers for variables and methods are:
• Public methods / variables- Accessible from anywhere inside the class, in the sub
class, in same script file as well as outside the script file.
• Private methods / variables- Accessible only in their own class. Starts with two
underscores.
15. Example: For access modifiers with data abstraction
• class student:
__a=10 #private variable
b=20 #public variable
def __private_method(self): #private method
print("Private method is called")
def public_method(self): #public method
print("public method is called")
print("a= ",self.__a) #can be accessible in same
class
s1=student()
# print("a= ",s1.__a) #generate error
print("b=",s1.b)
# s1.__private_method() #generate error
Output: b= 20
public method is called
a= 10
16. Encapsulation
• Encapsulation is a process to bind data and functions together into a
single unit i.e. class while abstraction is a process in which the data
inside the class is the hidden from outside world
17. Creating Constructor:
• Constructors are generally used for instantiating an object.
• The task of constructors is to initialize(assign values) to the data
members of the class when an object of class is created.
• In Python the __init__() method is called the constructor and is
always called when an object is created.
• Syntax of constructor declaration :
• def __init__(self):
# body of the constructor
18. Example: For creating constructor use_ _init_ _ method called
as constructor.
class student:
def __init__(self,rollno,name,age):
self.rollno=rollno
self.name=name
self.age=age
print("student object is created")
p1=student(11,"Ajay",20)
print("Roll No of student= ",p1.rollno)
print("Name No of student= ",p1.name)
print("Age No of student= ",p1.age)
Output:
student object is created
Roll No of student= 11
Name No of student= Ajay
Age No of student= 20
19. • Define a class rectangle using length and width.It has a method which
can compute area.
• Create a circle class and initialize it with radius. Make two methods
getarea and getcircumference inside this class
20. Types of Constructor:
• There are two types of constructor-
• Default constructor
• Parameterized constructor
21. Default constructor-
• The default constructor is simple constructor which does not accept any
arguments. Its definition has only one argument which is a reference to the
instance being constructed.
class student:
def __init__(self):
print("This is non parameterized constructor")
def show(self,name):
print("Hello",name)
s1=student()
s1.show("World")
22. Parameterized constructor-
• Constructor with parameters is known as parameterized constructor.
• The parameterized constructor take its first argument as a reference to the
instance being constructed known as self and the rest of the arguments are
provided by the programmer.
23. Example: For parameterized constructor
class student:
def __init__(self,name):
print("This is parameterized constructor")
self.name=name
def show(self):
print("Hello",self.name)
s1=student("World“)
s1.show()
24. Destructor:
• A class can define a special method called destructor with the help of _ _del_
_().
• It is invoked automatically when the instance (object) is about to be destroyed.
• It is mostly used to clean up non memory resources used by an instance(object).
Example: For Destructor
class student:
def __init__(self):
print("This is non parameterized constructor")
25. Example: For Destructor
class student:
def __init__(self):
print("This is non parameterized constructor")
def __del__(self):
print("Destructor called")
• s1=student()
• s2=student()
• del s1
26. Inheritance:
• The mechanism of designing and constructing classes from other classes is called
inheritance.
• Inheritance is the capability of one class to derive or inherit the properties from
some another class.
• Single Inheritance
• Multiple Inheritance
• Multilevel Inheritance
• Hierarchical Inheritance
27. Single Inheritance
• Single inheritance enables a derived class to inherit properties from a single
parent class
• Syntax:
Class A:
# Properties of class A
Class B(A):
# Class B inheriting property of class A
# more properties of class B
28. Example 1: Example of Inheritance without using constructor
class vehicle:
name="Maruti"
def display(self):
print("Name= ",self.name)
class category(vehicle):
price=400000
def disp_price(self):
print("price= ",self.price)
car1=category()
car1.display()
car1.disp_price()
29. Example 2: Example of Inheritance using constructor
class vehicle:
def __init__(self,name,price):
self.name=name
self.price=price
def display(self):
print("Name= ",self.name)
class category(vehicle):
def __init__(self,name,price):
vehicle.__init__(self,name,price) #pass data to base constructor
def disp_price(self):
print("price= ",self.price)
car1=category("Maruti",400000)
car1.display()
car1.disp_price()
30. Multilevel Inheritance:
• In multilevel inheritance, features of the base class and the derived class are
further inherited into the new derived class. This is similar to a relationship
representing a child and grandfather
• Syntax:
Class A:
# Properties of class A
Class B(A):
# Class B inheriting property of class A
# more properties of class B
Class C(B):
# Class C inheriting property of class B
# thus, Class C also inherits properties of class A
32. Multiple Inheritance:
• When a class can be derived from more than one base classes this type of
inheritance is called multiple inheritance. In multiple inheritance, all the features of
the base classes are inherited into the derived class.
Syntax:
Class A:
# variable of class A
# functions of class A
Class B:
# variable of class B
# functions of class B
Class C(A,B):
# Class C inheriting property of both class A and B
33. Example: Python program to demonstrate multiple inheritance
class Father:
def display1(self):
print("Father")
class Mother:
def display2(self):
print("Mother")
class Son(Father,Mother):
def display3(self):
print("Son")
s1 = Son()
s1.display3()
s1.display2()
s1.display1()
34. Hierarchical Inheritance:
• When more than one derived classes are created from a single base this type of
inheritence is called hierarchical inheritance. In this program, we have a parent
(base) class and two child (derived) classes.
35. Example : Python program to demonstrate Hierarchical inheritance
class Parent:
def func1(self):
print("This function is in parent class.")
class Child1(Parent):
def func2(self):
print("This function is in child 1.")
class Child2(Parent):
def func3(self):
print("This function is in child 2.")
object1 = Child1()
object1.func1()
object1.func2()