SlideShare a Scribd company logo
GOVERNMENT COLLEGE OF ENGINEERING AND
TEXTILE TECHNOLOGY, SERAMPORE
PRESENTATION ON
“Objects in Python"
Presented by
RAKESH SHAW (11001421024)
TEXTILE TECHNOLOGY (3rd year, 6th sem)
UNDER THE GUIDANCE OF SMT. PRIYANKA MA'AM
PAPER NAME :- INTRODUCTION TO PYTHON (OETT-601B)
PYTHON PLAYGROUND:
BUILDING WITH OBJECTS
CONTENTS​
Topic name​
INTRODUCTION TO PYTHON
CHARACTERISTICS OF PYTHON
OBJECT IN PYTHON
PYTHON CLASSES
NEED FOR CREATING A CLASS AND OBJECT IN PYTHON
DECLARING CLAAS OBJECTS (ALSO CALLED
INSTANTIATING A CLASS)
EXAMPLE OF PYTHON CLASS AND OBJECT
​ACKNOWLEDGEMENT, ​REFERENCES
SL. NO.
1.
2.
3.
4.
5.
6.
7.
8.
Page No.​
01
02
03 - 04
05
06
07
08 - 09
10
INTRODUCTION TO
PYTHON
• Python is a widely used
general-purpose, high level
programming language.
• It was initially designed by
Guido van Rossum in 1991 and
developed by Python Software
Foundation.
• It was mainly developed for
emphasis on code readability,
and its syntax allows
programmers to express
concepts in fewer lines of
code.
• Python is a programming
language that lets you work
quickly and integrate systems
more efficiently
1
CHARACTERISTICS OF PYTHON
Following are important characteristics of python
programming −
 It supports functional and
structured programming methods as well as
oop.
 It can be used as a scripting language or can be
compiled to byte-code for building large
applications.
 It provides very high-level dynamic data types
and supports dynamic type checking.
 It supports automatic garbage collection.
 It can be easily integrated with c, c++, com,
activex, corba, and java.
2
OBJECT IN PYTHON
• An object is a self-contained entity that
combines data (called attributes) and
behavior (called methods) into a single unit.
• Objects are concrete instances of a class.
• A class is like a blueprint that defines the
attributes (data) and methods (functions) an
object can have.
• Each object is its own unique entity with its
own set of data and functions.
3
An object consists of:
• State: It is represented by the attributes of an object. It
also reflects the properties of an object.
• Behavior: It is represented by the methods of an
object. It also reflects the response of an object to other
objects.
• Identity: It gives a unique name to an object and
enables one object to interact with other objects
4
PYTHON CLASSES
• A class is a user-defined blueprint or prototype from which objects are created.
• Classes provide a means of bundling data and functionality together.
• Creating a new class creates a new type of object, allowing new instances of that type to
be made.
• Each class instance can have attributes attached to it for maintaining its state.
• Class instances can also have methods (defined by their class) for modifying their state.
Some points on Python class:
• Classes are created by keyword class.
• Attributes are the variables that belong to a class.
• Attributes are always public and can be accessed using the dot (.) operator.
Eg.: My class.Myattribute
This Photo by Unknown author is licensed under CC BY-NC.
5
NEED FOR CREATING A CLASS AND OBJECT IN PYTHON
• To understand the need for creating a class and object in Python . let’s consider an
example, let’s say you wanted to track the number of dogs that may have different
attributes like breed and age. If a list is used, the first element could be the dog’s breed
while the second element could represent its age. Let’s suppose there are 100 different
dogs, then how would you know which element is supposed to be which? What if you
wanted to add other properties to these dogs? This lacks organization and it’s the exact
need for classes.
• Syntax: Class Definition
class ClassName:
# Statement
• Syntax: Object Definition
obj = ClassName()
print(obj.atrr)
6
DECLARING CLAAS OBJECTS (ALSO
CALLED INSTANTIATING A CLASS)
When an object of a class is created, the class is said
to be instantiated. All the instances share the
attributes and the behavior of the class. But the
values of those attributes, i.e. the state are unique for
each object. A single class may have any number of
instances.
Example:
7
EXAMPLE OF PYTHON CLASS AND OBJECT
Creating an object in python involves instantiating a class to create a new instance of that class.
This process is also referred to as object instantiation.
Here is an example of a python class and object:
class person:
def __init__(self, name, age):
self.Name = name
self.Age = age
def greet(self):
print(f"hello, my name is {self.Name} and I am {self.Age} years old.")
Person1 = person("john", 30)
person2 = person("mary", 25)
8
PERSON1.GREET()
PERSON2.GREET()
OUTPUT:
HELLO, MY NAME IS JOHN AND I AM 30 YEARS OLD.
Hello, my name is mary and i am 25 years old.
In this example, the person class is a blueprint for creating objects that represent
people. The __init__() method is a special method that is called when a new object is created. It takes
two arguments, name and age, and assigns them to the name and age attributes of the object.
The greet() method is a regular method that prints a greeting to the console. It takes no arguments, but it
uses the self keyword to access the name and age attributes of the object.
The person1 and person2 objects are instances of the person class. They have their own unique values
for the name and age attributes.
When the greet() method is called on the person1 and person2 objects, it prints a greeting to the console
that includes the values of the name and age attributes of the objects.
9
ACKNOWLEDGEMENT
I would like to express my gratitude to the Python programming language community for its
continuous efforts in developing and maintaining a versatile and powerful language. The concept
of objects in Python has played a pivotal role in shaping the language's success. I appreciate the
Python Software Foundation and all contributors for fostering an environment that encourages the
use of object-oriented programming principles, making Python an accessible and robust tool for
developers worldwide.
Finally, I would like to acknowledge the vast online resources, tutorials, and educational
platforms that have contributed immensely to the understanding of objects in Python. From
comprehensive documentation to interactive learning environments, these resources have been
instrumental in helping individuals grasp the intricacies of object-oriented programming in
Python, fostering a strong and supportive learning community.
REFERENCES
• https://www.geeksforgeeks.org/python-classes-and-objects/
• file:///C:/Users/user/Downloads/Notes%2011%20(1).pdf
10

More Related Content

Similar to Object in python tells about object oriented programming in python (20)

Lecture 4
Lecture 4Lecture 4
Lecture 4
talha ijaz
 
Object-Oriented Programming in Python.pptx
Object-Oriented Programming in Python.pptxObject-Oriented Programming in Python.pptx
Object-Oriented Programming in Python.pptx
ssuser4ab3a2
 
Creating class, self variables in Python
Creating class, self variables in PythonCreating class, self variables in Python
Creating class, self variables in Python
AditiPawaskar5
 
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Metaclasses – Python’s Object-Oriented Paradigm and Its MetaprogrammingMetaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Inexture Solutions
 
OOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptxOOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptx
ShobhitSrivastava15887
 
IPP-M5-C1-Classes _ Objects python -S2.pptx
IPP-M5-C1-Classes _ Objects python -S2.pptxIPP-M5-C1-Classes _ Objects python -S2.pptx
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
Ch 2 Library Classes.pdf
Ch 2 Library Classes.pdfCh 2 Library Classes.pdf
Ch 2 Library Classes.pdf
KavitaHegde4
 
Ch 2 Library Classes.pptx
Ch 2 Library Classes.pptxCh 2 Library Classes.pptx
Ch 2 Library Classes.pptx
KavitaHegde4
 
About Python
About PythonAbout Python
About Python
Shao-Chuan Wang
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
AshutoshTrivedi30
 
Python - object oriented
Python - object orientedPython - object oriented
Python - object oriented
Learnbay Datascience
 
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptxPYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
mru761077
 
Basics of Programming_Python__Lecture__3.ppt
Basics of Programming_Python__Lecture__3.pptBasics of Programming_Python__Lecture__3.ppt
Basics of Programming_Python__Lecture__3.ppt
geethar79
 
The Awesome Python Class Part-4
The Awesome Python Class Part-4The Awesome Python Class Part-4
The Awesome Python Class Part-4
Binay Kumar Ray
 
python1 object oriented programming.pptx
python1 object oriented programming.pptxpython1 object oriented programming.pptx
python1 object oriented programming.pptx
PravinBhargav1
 
JS-02-JavaScript-Objects.ppt
JS-02-JavaScript-Objects.pptJS-02-JavaScript-Objects.ppt
JS-02-JavaScript-Objects.ppt
MadhukarReddy74
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
ssuser8347a1
 
Programming with _Python__Lecture__3.ppt
Programming with _Python__Lecture__3.pptProgramming with _Python__Lecture__3.ppt
Programming with _Python__Lecture__3.ppt
geethar79
 
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptxoogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
BhojarajTheking
 
Object-Oriented Programming System presentation
Object-Oriented Programming System presentationObject-Oriented Programming System presentation
Object-Oriented Programming System presentation
PavanKumarPathipati
 
Object-Oriented Programming in Python.pptx
Object-Oriented Programming in Python.pptxObject-Oriented Programming in Python.pptx
Object-Oriented Programming in Python.pptx
ssuser4ab3a2
 
Creating class, self variables in Python
Creating class, self variables in PythonCreating class, self variables in Python
Creating class, self variables in Python
AditiPawaskar5
 
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Metaclasses – Python’s Object-Oriented Paradigm and Its MetaprogrammingMetaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Inexture Solutions
 
IPP-M5-C1-Classes _ Objects python -S2.pptx
IPP-M5-C1-Classes _ Objects python -S2.pptxIPP-M5-C1-Classes _ Objects python -S2.pptx
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
Ch 2 Library Classes.pdf
Ch 2 Library Classes.pdfCh 2 Library Classes.pdf
Ch 2 Library Classes.pdf
KavitaHegde4
 
Ch 2 Library Classes.pptx
Ch 2 Library Classes.pptxCh 2 Library Classes.pptx
Ch 2 Library Classes.pptx
KavitaHegde4
 
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptxPYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
mru761077
 
Basics of Programming_Python__Lecture__3.ppt
Basics of Programming_Python__Lecture__3.pptBasics of Programming_Python__Lecture__3.ppt
Basics of Programming_Python__Lecture__3.ppt
geethar79
 
The Awesome Python Class Part-4
The Awesome Python Class Part-4The Awesome Python Class Part-4
The Awesome Python Class Part-4
Binay Kumar Ray
 
python1 object oriented programming.pptx
python1 object oriented programming.pptxpython1 object oriented programming.pptx
python1 object oriented programming.pptx
PravinBhargav1
 
JS-02-JavaScript-Objects.ppt
JS-02-JavaScript-Objects.pptJS-02-JavaScript-Objects.ppt
JS-02-JavaScript-Objects.ppt
MadhukarReddy74
 
Programming with _Python__Lecture__3.ppt
Programming with _Python__Lecture__3.pptProgramming with _Python__Lecture__3.ppt
Programming with _Python__Lecture__3.ppt
geethar79
 
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptxoogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
oogshsvshsbhshhshvsvshsvsvhshshjshshhsvgps.pptx
BhojarajTheking
 
Object-Oriented Programming System presentation
Object-Oriented Programming System presentationObject-Oriented Programming System presentation
Object-Oriented Programming System presentation
PavanKumarPathipati
 

Recently uploaded (20)

Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Ad

Object in python tells about object oriented programming in python

  • 1. GOVERNMENT COLLEGE OF ENGINEERING AND TEXTILE TECHNOLOGY, SERAMPORE PRESENTATION ON “Objects in Python" Presented by RAKESH SHAW (11001421024) TEXTILE TECHNOLOGY (3rd year, 6th sem) UNDER THE GUIDANCE OF SMT. PRIYANKA MA'AM PAPER NAME :- INTRODUCTION TO PYTHON (OETT-601B)
  • 3. CONTENTS​ Topic name​ INTRODUCTION TO PYTHON CHARACTERISTICS OF PYTHON OBJECT IN PYTHON PYTHON CLASSES NEED FOR CREATING A CLASS AND OBJECT IN PYTHON DECLARING CLAAS OBJECTS (ALSO CALLED INSTANTIATING A CLASS) EXAMPLE OF PYTHON CLASS AND OBJECT ​ACKNOWLEDGEMENT, ​REFERENCES SL. NO. 1. 2. 3. 4. 5. 6. 7. 8. Page No.​ 01 02 03 - 04 05 06 07 08 - 09 10
  • 4. INTRODUCTION TO PYTHON • Python is a widely used general-purpose, high level programming language. • It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. • It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code. • Python is a programming language that lets you work quickly and integrate systems more efficiently 1
  • 5. CHARACTERISTICS OF PYTHON Following are important characteristics of python programming −  It supports functional and structured programming methods as well as oop.  It can be used as a scripting language or can be compiled to byte-code for building large applications.  It provides very high-level dynamic data types and supports dynamic type checking.  It supports automatic garbage collection.  It can be easily integrated with c, c++, com, activex, corba, and java. 2
  • 6. OBJECT IN PYTHON • An object is a self-contained entity that combines data (called attributes) and behavior (called methods) into a single unit. • Objects are concrete instances of a class. • A class is like a blueprint that defines the attributes (data) and methods (functions) an object can have. • Each object is its own unique entity with its own set of data and functions. 3
  • 7. An object consists of: • State: It is represented by the attributes of an object. It also reflects the properties of an object. • Behavior: It is represented by the methods of an object. It also reflects the response of an object to other objects. • Identity: It gives a unique name to an object and enables one object to interact with other objects 4
  • 8. PYTHON CLASSES • A class is a user-defined blueprint or prototype from which objects are created. • Classes provide a means of bundling data and functionality together. • Creating a new class creates a new type of object, allowing new instances of that type to be made. • Each class instance can have attributes attached to it for maintaining its state. • Class instances can also have methods (defined by their class) for modifying their state. Some points on Python class: • Classes are created by keyword class. • Attributes are the variables that belong to a class. • Attributes are always public and can be accessed using the dot (.) operator. Eg.: My class.Myattribute This Photo by Unknown author is licensed under CC BY-NC. 5
  • 9. NEED FOR CREATING A CLASS AND OBJECT IN PYTHON • To understand the need for creating a class and object in Python . let’s consider an example, let’s say you wanted to track the number of dogs that may have different attributes like breed and age. If a list is used, the first element could be the dog’s breed while the second element could represent its age. Let’s suppose there are 100 different dogs, then how would you know which element is supposed to be which? What if you wanted to add other properties to these dogs? This lacks organization and it’s the exact need for classes. • Syntax: Class Definition class ClassName: # Statement • Syntax: Object Definition obj = ClassName() print(obj.atrr) 6
  • 10. DECLARING CLAAS OBJECTS (ALSO CALLED INSTANTIATING A CLASS) When an object of a class is created, the class is said to be instantiated. All the instances share the attributes and the behavior of the class. But the values of those attributes, i.e. the state are unique for each object. A single class may have any number of instances. Example: 7
  • 11. EXAMPLE OF PYTHON CLASS AND OBJECT Creating an object in python involves instantiating a class to create a new instance of that class. This process is also referred to as object instantiation. Here is an example of a python class and object: class person: def __init__(self, name, age): self.Name = name self.Age = age def greet(self): print(f"hello, my name is {self.Name} and I am {self.Age} years old.") Person1 = person("john", 30) person2 = person("mary", 25) 8
  • 12. PERSON1.GREET() PERSON2.GREET() OUTPUT: HELLO, MY NAME IS JOHN AND I AM 30 YEARS OLD. Hello, my name is mary and i am 25 years old. In this example, the person class is a blueprint for creating objects that represent people. The __init__() method is a special method that is called when a new object is created. It takes two arguments, name and age, and assigns them to the name and age attributes of the object. The greet() method is a regular method that prints a greeting to the console. It takes no arguments, but it uses the self keyword to access the name and age attributes of the object. The person1 and person2 objects are instances of the person class. They have their own unique values for the name and age attributes. When the greet() method is called on the person1 and person2 objects, it prints a greeting to the console that includes the values of the name and age attributes of the objects. 9
  • 13. ACKNOWLEDGEMENT I would like to express my gratitude to the Python programming language community for its continuous efforts in developing and maintaining a versatile and powerful language. The concept of objects in Python has played a pivotal role in shaping the language's success. I appreciate the Python Software Foundation and all contributors for fostering an environment that encourages the use of object-oriented programming principles, making Python an accessible and robust tool for developers worldwide. Finally, I would like to acknowledge the vast online resources, tutorials, and educational platforms that have contributed immensely to the understanding of objects in Python. From comprehensive documentation to interactive learning environments, these resources have been instrumental in helping individuals grasp the intricacies of object-oriented programming in Python, fostering a strong and supportive learning community. REFERENCES • https://www.geeksforgeeks.org/python-classes-and-objects/ • file:///C:/Users/user/Downloads/Notes%2011%20(1).pdf 10