SlideShare a Scribd company logo
 Python Objects
 Built-in Types
 Standard Type Operators
Value Comparison
Object Identity Comparison
Boolean
 Standard Type Built-in Functions
 Categorizing the Standard Types
 Unsupported Types
 Python uses the object model abstraction for data storage.
 Any construct which contains any type of value is an
object.
 Although Python is classified as an "object-oriented
programming language," OOP is not required to create
perfectly working Python applications.
 All Python objects have the following three
characteristics: an identity, a type, and a value.
IDENTITY Unique identifier that differentiates an object from all
others. Any object's identifier can be
obtained using the id() built-in function.
TYPE An object's type indicates what kind of values an
object can hold, what operations can be
applied to such objects, and what behavioral rules
these objects are subject to. You can use the
type() built-in function to reveal the type of a Python
object.
VALUE Data item that is represented by an object.
 All three are assigned on object creation and are read-
only with one exception, the value.
 If an object supports updates, its value can be changed;
otherwise, it is also read-only.
 Whether an object's value can be changed is known as an
object's mutability.
 Object Attributes
 Certain Python objects have attributes, data values or
executable code such as methods, associated with them.
 Attributes are accessed in the dotted attribute notation,
which includes the name of the associated object.
 Objects with data attributes include classes, class
instances, modules, complex numbers, and files.
 Standard Types
 Numbers (four separate sub-types)
 Regular or "Plain" Integer
 Long Integer
 Floating Point Real Number
 Complex Number
 String
 List
 Tuple
 Dictionary
 We will also refer to standard types as "primitive data
types" in this text because these types represent the
primitive data types that Python provides.
 Other Built-in Types
 Type
 None
 File
 Function
 Module
 Class
 Class Instance
 Method
 An object's set of inherent behaviors and characteristics
(must be defined somewhere, an object's type is a logical
place for this information.
 The amount of information necessary to describe a type
cannot fit into a single string; therefore types cannot
simply be strings, nor should this information be stored
with the data, so we are back to types as objects.
 We will formally introduce the type() built-in function.
The syntax is as follows:
type(object)
 The type() built-in function takes object and returns its
type. The return object is a type object.
 >>> type(4) #int type
 <type 'int'>
 >>>
 >>> type('Hello World!') #string type
 <type 'string'>
 >>>
 >>> type(type(4)) #type type
 <type 'type'>
 Python has a special type known as the Null object.
 It has only one value, None. The type of None is also
None. It does not have any operators or built-in functions.
 If you are familiar with C, the closest analogy to the
None type is void, while the None value is similar to the
C value of NULL.
 None has no attributes and always evaluates to having a
Boolean false value.
 Internal Types
 Code
 Frame
 Traceback
 Slice
 Ellipsis
 Xrange
1) Code objects
Code objects are executable pieces of Python source that
are byte-compiled, usually as return values from calling the
compile() built-in function.
Such objects are appropriate for execution by either exec
or by the eval() built-in function.
2) Frames
 These are objects representing execution stack frames in
Python.
 Frame objects contain all the information the Python
interpreter needs to know during a runtime execution
environment.
 Each function call results in a new frame object, and for
each frame object, a C stack frame is created as well.
 One place where you can access a frame object is in a
traceback object
3) Tracebacks
 When you make an error in Python, an exception is
raised. If exceptions are not caught or "handled," the
interpreter exits with some diagnostic information similar
to the output shown below:
Traceback (innermost last):
File "<stdin>", line N?, in ???
ErrorName: error reason
 The traceback object is just a data item that holds the
stack trace information for an exception and is created
when an exception occurs.
 If a handler is provided for an exception, this handler is
given access to the traceback object.
4) Slice Objects
 Slice objects are created when using the Python extended
slice syntax. This extended syntax allows for different types
of indexing.
 These various types of indexing include stride indexing,
multi-dimensional indexing, and indexing using the Ellipsis
type.
 The syntax for multi-dimensional indexing is
sequence[start1 : end1, start2 : end2], or using the ellipsis,
sequence[…, start1 : end1].
 Slice objects can also be generated by the slice() built-in
function.
 Stride indexing for sequence types allows for a third slice
element that allows for "step"-like access with a syntax of
sequence[starting_index : ending_index : stride].
5) Ellipsis
 Ellipsis objects are used in extended slice notations as
demonstrated above.
 These objects are used to represent the actual ellipses in
the slice syntax (…).
 Like the Null object, ellipsis objects also have a single
name, Ellipsis, and has a Boolean true value at all times.
6) Xranges
 XRange objects are created by the built-in function
xrange(), a sibling of the range() built-in function and
used when memory is limited and for when range()
generates an unusually large data set.
 Value Comparison
 Comparison operators are used to determine equality of
two data values between members of the same type.
 These comparison operators are supported for all built-in
types.
 Comparisons yield true or false values, based on the
validity of the comparison expression.
 Python chooses to interpret these values as the plain
integers 0 and 1 for false and true, respectively, meaning
that each comparison will result in one of those two
possible values.
operator function
expr1 < expr2 expr1 is less than expr2
expr1 > expr2 expr1 is greater than expr2
expr1 <= expr2 expr1 is less than or equal to
expr2
expr1 >= expr2 expr1 is greater than or equal
to expr2
expr1 == expr2 expr1 is equal to expr2
expr1 != expr2 expr1 is not equal to expr2
expr1 <> expr2 expr1 is not equal to expr2
 Object Identity Comparison
 In addition to value comparisons, Python also supports
the notion of directly comparing objects themselves.
 Objects can be assigned to other variables (by reference).
 Because each variable points to the same (shared) data
object, any change effected through one variable will
change the object and hence be reflected through all
references to the same object.
 Example 1: foo1 and foo2 reference the same object
 foo1 = foo2 = 4
 Assigning the numeric value of 4 to both the foo1 and
foo2 variables, resulting in both foo1 and foo2 aliased to
the same object.
 Example 2: foo1 and foo2 reference the same object
 foo1 = 4
 foo2 = foo1
 A numeric object with value 4 is created, then assigned to
one variable. When foo2 = foo1 occurs, foo2 is directed
to the same object as foo1 since Python deals with objects
by passing references. foo2 then becomes a new and
additional reference for the original value. So both foo1
and foo2 now point to the same object.
 Example 3: foo1 and foo2 reference different objects
 foo1 = 4
 foo2 = 1 + 3
 First, a numeric object is created, then assigned to foo1.
Then a second numeric object is created, and this time
assigned to foo2. Although both objects are storing the
exact same value, there are indeed two distinct objects in
the system, with foo1 pointing to the first, and foo2 being
a reference to the second.
operator function
obj1 is obj2 obj1 is the same object as
obj2
obj1 is not obj2 obj1 is not the same object
as obj2
 Python also provides some built-in functions that can be
applied to all the basic object types: cmp(), repr(), str(),
type(), and the single reverse or back quotes ( '' ) operator,
which is functionally-equivalent to repr().
FUNCTION OPERATION
cmp(obj1, obj2) compares obj1 and obj2, returns integer i where:
i < 0 if obj1 < obj2
i > 0 if obj1 > obj2
i == 0 if obj1 == obj2
repr(obj)/' obj' returns evaluatable string representation of obj
str(obj) returns printable string representation of obj
type(obj) determines type of obj and return type object
 If we were to be maximally verbose in describing the standard
types, we would probably call them something like Python's
"basic built-in data object primitive types”.
 "Basic," indicating that these are the standard or core types that
Python provide
 "Built-in," due to the fact that types these come default with
Python.
 "Data," because they are used for general data storage
 "Object," because objects are the default abstraction for data
and functionality
 "Primitive," because these types provide the lowest-level
granularity of data storage
 "Types," because that's what they are: data types!
 There are three different models we have come up with to
help categorize the standard types, with each model
showing us the interrelationships between the types.
Data Type Storage
Model
Update
Model
Access
Model
numbers literal/scalar immutable direct
strings literal/scalar immutable Sequence
lists container mutable sequence
tuples container immutable sequence
dictionaries container mutable mapping
 The first way we can categorize the types is by how many
objects can be stored in an object of this type.
 Python's types, as well as types from most other
languages, can hold either single or multiple values.
 A type which holds a single object we will call literal or
scalar storage, and those which can hold multiple objects
we will refer to as container storage.
Storage model category Python types that fit
category
literal/scalar numbers (all numeric
types), strings
container lists, tuples, dictionaries
 That certain types allow their values to be updated and
others do not. Mutable objects are those whose values can
be changed, and immutable objects are those whose
values cannot be changed.
Update model category Python types that fit category
mutable lists, dictionaries
immutable numbers, strings, tuples
 x = 'Python numbers and strings'
 print id(x)
 x = 'are immutable?!? What gives?'
 print id(x)
 i = 0
 print id(i)
 i = i + 1
 print id(i)
Output
16191392
16191232
7749552
7749600
 By this, we mean, how do we access the values of our
stored data? There are three categories under the access
model: direct, sequence, and mapping.
 Direct types indicate single element, non-container types.
All numeric types fit into this category.
access model
category
types that fit
category
direct numbers
sequence strings, lists, tuples
mapping dictionaries
 Sequence types are those whose elements are
sequentially-accessible via index values starting at 0.
 Accessed items can be either single elements or in
groups, better known as slices.
 Types which fall into this category include strings, lists,
and tuples.
 Mapping types are similar to the indexing properties of
sequences, except instead of indexing on a sequential
numeric offset, elements (values) are unordered and
accessed with a key, thus making mapping types a set of
hashed key-value pairs.
 Giving a list of types that are not supported by Python.
 Boolean
 Unlike Pascal or Java, Python does not feature the
Boolean type. Use integers instead.
 char or byte
 Python does not have a char or byte type to hold either
single character or 8-bit integers. Use strings of length
one for characters and integers for 8-bit numbers.
 int vs. short vs. long
 Python's plain integers are the universal "standard" integer
type, obviating the need for three different integer types,
i.e., C's int, short, and long.
 For the record, Python's integers are implemented as C
longs. For values larger in magnitude than regular integers,
use Python's long integer.
 float vs. double
 C has both a single precision float type and double-
precision double type. Python's float type is actually a C
double.
 Python does not support a single-precision floating point
type because its benefits are outweighed by the overhead
required to support two types of floating point types.
 PYTHON OBJECTS - Copy.pptx
Ad

More Related Content

What's hot (20)

Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
AbhishekMourya36
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
Mohammed Sikander
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
How to download and install Python - lesson 2
How to download and install Python - lesson 2How to download and install Python - lesson 2
How to download and install Python - lesson 2
Shohel Rana
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
Praveen M Jigajinni
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
Karudaiyar Ganapathy
 
Python GUI
Python GUIPython GUI
Python GUI
LusciousLarryDas
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
Praveen M Jigajinni
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
Panimalar Engineering College
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
SachiniGunawardana
 
C++ programming
C++ programmingC++ programming
C++ programming
Emertxe Information Technologies Pvt Ltd
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
How to download and install Python - lesson 2
How to download and install Python - lesson 2How to download and install Python - lesson 2
How to download and install Python - lesson 2
Shohel Rana
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
SachiniGunawardana
 

Similar to PYTHON OBJECTS - Copy.pptx (20)

E-Notes_3720_Content_Document_20250107032323PM.pdf
E-Notes_3720_Content_Document_20250107032323PM.pdfE-Notes_3720_Content_Document_20250107032323PM.pdf
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
Tareq Hasan
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
software construction and development week 3 Python lists, tuples, dictionari...
software construction and development week 3 Python lists, tuples, dictionari...software construction and development week 3 Python lists, tuples, dictionari...
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
About Python
About PythonAbout Python
About Python
Shao-Chuan Wang
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
swati kushwaha
 
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMINGOOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
NagarathnaRajur2
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
alaparthi
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
MohammedAlYemeni1
 
Week 2 Lesson Natural Processing Language.pptx
Week 2 Lesson Natural Processing Language.pptxWeek 2 Lesson Natural Processing Language.pptx
Week 2 Lesson Natural Processing Language.pptx
balmedinajewelanne
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
nurkhaledah
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
Manish Jangir
 
4. Data Handling computer shcience pdf s
4. Data Handling computer shcience pdf s4. Data Handling computer shcience pdf s
4. Data Handling computer shcience pdf s
TonyTech2
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
Upender Upr
 
DAY_1.3.pptx
DAY_1.3.pptxDAY_1.3.pptx
DAY_1.3.pptx
ishasharma835109
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
Chui-Wen Chiu
 
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
 
unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
ssuser2e84e4
 
Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database concepts
Temesgenthanks
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
E-Notes_3720_Content_Document_20250107032323PM.pdf
E-Notes_3720_Content_Document_20250107032323PM.pdfE-Notes_3720_Content_Document_20250107032323PM.pdf
E-Notes_3720_Content_Document_20250107032323PM.pdf
aayushihirpara297
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
Tareq Hasan
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
software construction and development week 3 Python lists, tuples, dictionari...
software construction and development week 3 Python lists, tuples, dictionari...software construction and development week 3 Python lists, tuples, dictionari...
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
swati kushwaha
 
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMINGOOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
NagarathnaRajur2
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
alaparthi
 
Week 2 Lesson Natural Processing Language.pptx
Week 2 Lesson Natural Processing Language.pptxWeek 2 Lesson Natural Processing Language.pptx
Week 2 Lesson Natural Processing Language.pptx
balmedinajewelanne
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
nurkhaledah
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
Manish Jangir
 
4. Data Handling computer shcience pdf s
4. Data Handling computer shcience pdf s4. Data Handling computer shcience pdf s
4. Data Handling computer shcience pdf s
TonyTech2
 
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
 
Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database concepts
Temesgenthanks
 
Ad

Recently uploaded (20)

A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
Sérgio Sacani
 
Subject name: Introduction to psychology
Subject name: Introduction to psychologySubject name: Introduction to psychology
Subject name: Introduction to psychology
beebussy155
 
Seismic evidence of liquid water at the base of Mars' upper crust
Seismic evidence of liquid water at the base of Mars' upper crustSeismic evidence of liquid water at the base of Mars' upper crust
Seismic evidence of liquid water at the base of Mars' upper crust
Sérgio Sacani
 
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.pptSULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
HRUTUJA WAGH
 
Preclinical Advances in Nuclear Neurology.pptx
Preclinical Advances in Nuclear Neurology.pptxPreclinical Advances in Nuclear Neurology.pptx
Preclinical Advances in Nuclear Neurology.pptx
MahitaLaveti
 
Components of the Human Circulatory System.pptx
Components of the Human  Circulatory System.pptxComponents of the Human  Circulatory System.pptx
Components of the Human Circulatory System.pptx
autumnstreaks
 
Top 10 Biotech Startups for Beginners.pptx
Top 10 Biotech Startups for Beginners.pptxTop 10 Biotech Startups for Beginners.pptx
Top 10 Biotech Startups for Beginners.pptx
alexbagheriam
 
Carboxylic-Acid-Derivatives.lecture.presentation
Carboxylic-Acid-Derivatives.lecture.presentationCarboxylic-Acid-Derivatives.lecture.presentation
Carboxylic-Acid-Derivatives.lecture.presentation
GLAEXISAJULGA
 
dsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentationdsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentation
JessaMaeDacayo
 
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptxA CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
ANJALICHANDRASEKARAN
 
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Professional Content Writing's
 
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth UniversityEuclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Peter Coles
 
Brief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdfBrief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdf
BharathKumar556689
 
External Application in Homoeopathy- Definition,Scope and Types.
External Application  in Homoeopathy- Definition,Scope and Types.External Application  in Homoeopathy- Definition,Scope and Types.
External Application in Homoeopathy- Definition,Scope and Types.
AdharshnaPatrick
 
Somato_Sensory _ somatomotor_Nervous_System.pptx
Somato_Sensory _ somatomotor_Nervous_System.pptxSomato_Sensory _ somatomotor_Nervous_System.pptx
Somato_Sensory _ somatomotor_Nervous_System.pptx
klynct
 
Black hole and its division and categories
Black hole and its division and categoriesBlack hole and its division and categories
Black hole and its division and categories
MSafiullahALawi
 
Controls over genes.ppt. Gene Expression
Controls over genes.ppt. Gene ExpressionControls over genes.ppt. Gene Expression
Controls over genes.ppt. Gene Expression
NABIHANAEEM2
 
Proprioceptors_ receptors of muscle_tendon
Proprioceptors_ receptors of muscle_tendonProprioceptors_ receptors of muscle_tendon
Proprioceptors_ receptors of muscle_tendon
klynct
 
CORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptxCORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptx
DharaniJajula
 
Introduction to Black Hole and how its formed
Introduction to Black Hole and how its formedIntroduction to Black Hole and how its formed
Introduction to Black Hole and how its formed
MSafiullahALawi
 
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
A Massive Black Hole 0.8kpc from the Host Nucleus Revealed by the Offset Tida...
Sérgio Sacani
 
Subject name: Introduction to psychology
Subject name: Introduction to psychologySubject name: Introduction to psychology
Subject name: Introduction to psychology
beebussy155
 
Seismic evidence of liquid water at the base of Mars' upper crust
Seismic evidence of liquid water at the base of Mars' upper crustSeismic evidence of liquid water at the base of Mars' upper crust
Seismic evidence of liquid water at the base of Mars' upper crust
Sérgio Sacani
 
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.pptSULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
SULPHONAMIDES AND SULFONES Medicinal Chemistry III.ppt
HRUTUJA WAGH
 
Preclinical Advances in Nuclear Neurology.pptx
Preclinical Advances in Nuclear Neurology.pptxPreclinical Advances in Nuclear Neurology.pptx
Preclinical Advances in Nuclear Neurology.pptx
MahitaLaveti
 
Components of the Human Circulatory System.pptx
Components of the Human  Circulatory System.pptxComponents of the Human  Circulatory System.pptx
Components of the Human Circulatory System.pptx
autumnstreaks
 
Top 10 Biotech Startups for Beginners.pptx
Top 10 Biotech Startups for Beginners.pptxTop 10 Biotech Startups for Beginners.pptx
Top 10 Biotech Startups for Beginners.pptx
alexbagheriam
 
Carboxylic-Acid-Derivatives.lecture.presentation
Carboxylic-Acid-Derivatives.lecture.presentationCarboxylic-Acid-Derivatives.lecture.presentation
Carboxylic-Acid-Derivatives.lecture.presentation
GLAEXISAJULGA
 
dsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentationdsDNA-ASF, asfaviridae, virus in virology presentation
dsDNA-ASF, asfaviridae, virus in virology presentation
JessaMaeDacayo
 
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptxA CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
A CASE OF MULTINODULAR GOITRE,clinical presentation and management.pptx
ANJALICHANDRASEKARAN
 
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Discrete choice experiments: Environmental Improvements to Airthrey Loch Lake...
Professional Content Writing's
 
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth UniversityEuclid: The Story So far, a Departmental Colloquium at Maynooth University
Euclid: The Story So far, a Departmental Colloquium at Maynooth University
Peter Coles
 
Brief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdfBrief Presentation on Garment Washing.pdf
Brief Presentation on Garment Washing.pdf
BharathKumar556689
 
External Application in Homoeopathy- Definition,Scope and Types.
External Application  in Homoeopathy- Definition,Scope and Types.External Application  in Homoeopathy- Definition,Scope and Types.
External Application in Homoeopathy- Definition,Scope and Types.
AdharshnaPatrick
 
Somato_Sensory _ somatomotor_Nervous_System.pptx
Somato_Sensory _ somatomotor_Nervous_System.pptxSomato_Sensory _ somatomotor_Nervous_System.pptx
Somato_Sensory _ somatomotor_Nervous_System.pptx
klynct
 
Black hole and its division and categories
Black hole and its division and categoriesBlack hole and its division and categories
Black hole and its division and categories
MSafiullahALawi
 
Controls over genes.ppt. Gene Expression
Controls over genes.ppt. Gene ExpressionControls over genes.ppt. Gene Expression
Controls over genes.ppt. Gene Expression
NABIHANAEEM2
 
Proprioceptors_ receptors of muscle_tendon
Proprioceptors_ receptors of muscle_tendonProprioceptors_ receptors of muscle_tendon
Proprioceptors_ receptors of muscle_tendon
klynct
 
CORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptxCORONARY ARTERY BYPASS GRAFTING (1).pptx
CORONARY ARTERY BYPASS GRAFTING (1).pptx
DharaniJajula
 
Introduction to Black Hole and how its formed
Introduction to Black Hole and how its formedIntroduction to Black Hole and how its formed
Introduction to Black Hole and how its formed
MSafiullahALawi
 
Ad

PYTHON OBJECTS - Copy.pptx

  • 1.  Python Objects  Built-in Types  Standard Type Operators Value Comparison Object Identity Comparison Boolean  Standard Type Built-in Functions  Categorizing the Standard Types  Unsupported Types
  • 2.  Python uses the object model abstraction for data storage.  Any construct which contains any type of value is an object.  Although Python is classified as an "object-oriented programming language," OOP is not required to create perfectly working Python applications.
  • 3.  All Python objects have the following three characteristics: an identity, a type, and a value. IDENTITY Unique identifier that differentiates an object from all others. Any object's identifier can be obtained using the id() built-in function. TYPE An object's type indicates what kind of values an object can hold, what operations can be applied to such objects, and what behavioral rules these objects are subject to. You can use the type() built-in function to reveal the type of a Python object. VALUE Data item that is represented by an object.
  • 4.  All three are assigned on object creation and are read- only with one exception, the value.  If an object supports updates, its value can be changed; otherwise, it is also read-only.  Whether an object's value can be changed is known as an object's mutability.  Object Attributes  Certain Python objects have attributes, data values or executable code such as methods, associated with them.  Attributes are accessed in the dotted attribute notation, which includes the name of the associated object.  Objects with data attributes include classes, class instances, modules, complex numbers, and files.
  • 5.  Standard Types  Numbers (four separate sub-types)  Regular or "Plain" Integer  Long Integer  Floating Point Real Number  Complex Number  String  List  Tuple  Dictionary  We will also refer to standard types as "primitive data types" in this text because these types represent the primitive data types that Python provides.
  • 6.  Other Built-in Types  Type  None  File  Function  Module  Class  Class Instance  Method
  • 7.  An object's set of inherent behaviors and characteristics (must be defined somewhere, an object's type is a logical place for this information.  The amount of information necessary to describe a type cannot fit into a single string; therefore types cannot simply be strings, nor should this information be stored with the data, so we are back to types as objects.  We will formally introduce the type() built-in function. The syntax is as follows: type(object)  The type() built-in function takes object and returns its type. The return object is a type object.
  • 8.  >>> type(4) #int type  <type 'int'>  >>>  >>> type('Hello World!') #string type  <type 'string'>  >>>  >>> type(type(4)) #type type  <type 'type'>
  • 9.  Python has a special type known as the Null object.  It has only one value, None. The type of None is also None. It does not have any operators or built-in functions.  If you are familiar with C, the closest analogy to the None type is void, while the None value is similar to the C value of NULL.  None has no attributes and always evaluates to having a Boolean false value.
  • 10.  Internal Types  Code  Frame  Traceback  Slice  Ellipsis  Xrange 1) Code objects Code objects are executable pieces of Python source that are byte-compiled, usually as return values from calling the compile() built-in function. Such objects are appropriate for execution by either exec or by the eval() built-in function.
  • 11. 2) Frames  These are objects representing execution stack frames in Python.  Frame objects contain all the information the Python interpreter needs to know during a runtime execution environment.  Each function call results in a new frame object, and for each frame object, a C stack frame is created as well.  One place where you can access a frame object is in a traceback object
  • 12. 3) Tracebacks  When you make an error in Python, an exception is raised. If exceptions are not caught or "handled," the interpreter exits with some diagnostic information similar to the output shown below: Traceback (innermost last): File "<stdin>", line N?, in ??? ErrorName: error reason  The traceback object is just a data item that holds the stack trace information for an exception and is created when an exception occurs.  If a handler is provided for an exception, this handler is given access to the traceback object.
  • 13. 4) Slice Objects  Slice objects are created when using the Python extended slice syntax. This extended syntax allows for different types of indexing.  These various types of indexing include stride indexing, multi-dimensional indexing, and indexing using the Ellipsis type.  The syntax for multi-dimensional indexing is sequence[start1 : end1, start2 : end2], or using the ellipsis, sequence[…, start1 : end1].  Slice objects can also be generated by the slice() built-in function.  Stride indexing for sequence types allows for a third slice element that allows for "step"-like access with a syntax of sequence[starting_index : ending_index : stride].
  • 14. 5) Ellipsis  Ellipsis objects are used in extended slice notations as demonstrated above.  These objects are used to represent the actual ellipses in the slice syntax (…).  Like the Null object, ellipsis objects also have a single name, Ellipsis, and has a Boolean true value at all times. 6) Xranges  XRange objects are created by the built-in function xrange(), a sibling of the range() built-in function and used when memory is limited and for when range() generates an unusually large data set.
  • 15.  Value Comparison  Comparison operators are used to determine equality of two data values between members of the same type.  These comparison operators are supported for all built-in types.  Comparisons yield true or false values, based on the validity of the comparison expression.  Python chooses to interpret these values as the plain integers 0 and 1 for false and true, respectively, meaning that each comparison will result in one of those two possible values.
  • 16. operator function expr1 < expr2 expr1 is less than expr2 expr1 > expr2 expr1 is greater than expr2 expr1 <= expr2 expr1 is less than or equal to expr2 expr1 >= expr2 expr1 is greater than or equal to expr2 expr1 == expr2 expr1 is equal to expr2 expr1 != expr2 expr1 is not equal to expr2 expr1 <> expr2 expr1 is not equal to expr2
  • 17.  Object Identity Comparison  In addition to value comparisons, Python also supports the notion of directly comparing objects themselves.  Objects can be assigned to other variables (by reference).  Because each variable points to the same (shared) data object, any change effected through one variable will change the object and hence be reflected through all references to the same object.  Example 1: foo1 and foo2 reference the same object  foo1 = foo2 = 4  Assigning the numeric value of 4 to both the foo1 and foo2 variables, resulting in both foo1 and foo2 aliased to the same object.
  • 18.  Example 2: foo1 and foo2 reference the same object  foo1 = 4  foo2 = foo1  A numeric object with value 4 is created, then assigned to one variable. When foo2 = foo1 occurs, foo2 is directed to the same object as foo1 since Python deals with objects by passing references. foo2 then becomes a new and additional reference for the original value. So both foo1 and foo2 now point to the same object.  Example 3: foo1 and foo2 reference different objects  foo1 = 4  foo2 = 1 + 3
  • 19.  First, a numeric object is created, then assigned to foo1. Then a second numeric object is created, and this time assigned to foo2. Although both objects are storing the exact same value, there are indeed two distinct objects in the system, with foo1 pointing to the first, and foo2 being a reference to the second. operator function obj1 is obj2 obj1 is the same object as obj2 obj1 is not obj2 obj1 is not the same object as obj2
  • 20.  Python also provides some built-in functions that can be applied to all the basic object types: cmp(), repr(), str(), type(), and the single reverse or back quotes ( '' ) operator, which is functionally-equivalent to repr(). FUNCTION OPERATION cmp(obj1, obj2) compares obj1 and obj2, returns integer i where: i < 0 if obj1 < obj2 i > 0 if obj1 > obj2 i == 0 if obj1 == obj2 repr(obj)/' obj' returns evaluatable string representation of obj str(obj) returns printable string representation of obj type(obj) determines type of obj and return type object
  • 21.  If we were to be maximally verbose in describing the standard types, we would probably call them something like Python's "basic built-in data object primitive types”.  "Basic," indicating that these are the standard or core types that Python provide  "Built-in," due to the fact that types these come default with Python.  "Data," because they are used for general data storage  "Object," because objects are the default abstraction for data and functionality  "Primitive," because these types provide the lowest-level granularity of data storage  "Types," because that's what they are: data types!
  • 22.  There are three different models we have come up with to help categorize the standard types, with each model showing us the interrelationships between the types. Data Type Storage Model Update Model Access Model numbers literal/scalar immutable direct strings literal/scalar immutable Sequence lists container mutable sequence tuples container immutable sequence dictionaries container mutable mapping
  • 23.  The first way we can categorize the types is by how many objects can be stored in an object of this type.  Python's types, as well as types from most other languages, can hold either single or multiple values.  A type which holds a single object we will call literal or scalar storage, and those which can hold multiple objects we will refer to as container storage. Storage model category Python types that fit category literal/scalar numbers (all numeric types), strings container lists, tuples, dictionaries
  • 24.  That certain types allow their values to be updated and others do not. Mutable objects are those whose values can be changed, and immutable objects are those whose values cannot be changed. Update model category Python types that fit category mutable lists, dictionaries immutable numbers, strings, tuples
  • 25.  x = 'Python numbers and strings'  print id(x)  x = 'are immutable?!? What gives?'  print id(x)  i = 0  print id(i)  i = i + 1  print id(i) Output 16191392 16191232 7749552 7749600
  • 26.  By this, we mean, how do we access the values of our stored data? There are three categories under the access model: direct, sequence, and mapping.  Direct types indicate single element, non-container types. All numeric types fit into this category. access model category types that fit category direct numbers sequence strings, lists, tuples mapping dictionaries
  • 27.  Sequence types are those whose elements are sequentially-accessible via index values starting at 0.  Accessed items can be either single elements or in groups, better known as slices.  Types which fall into this category include strings, lists, and tuples.  Mapping types are similar to the indexing properties of sequences, except instead of indexing on a sequential numeric offset, elements (values) are unordered and accessed with a key, thus making mapping types a set of hashed key-value pairs.
  • 28.  Giving a list of types that are not supported by Python.  Boolean  Unlike Pascal or Java, Python does not feature the Boolean type. Use integers instead.  char or byte  Python does not have a char or byte type to hold either single character or 8-bit integers. Use strings of length one for characters and integers for 8-bit numbers.
  • 29.  int vs. short vs. long  Python's plain integers are the universal "standard" integer type, obviating the need for three different integer types, i.e., C's int, short, and long.  For the record, Python's integers are implemented as C longs. For values larger in magnitude than regular integers, use Python's long integer.  float vs. double  C has both a single precision float type and double- precision double type. Python's float type is actually a C double.  Python does not support a single-precision floating point type because its benefits are outweighed by the overhead required to support two types of floating point types.
  翻译: