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

More Related Content

PDF
What is Python Lambda Function? Python Tutorial | Edureka
PPTX
Functions in Python
PPTX
Variables in python
PDF
Python functions
PDF
Strings in python
PPTX
Python Functions
PPSX
Modules and packages in python
PDF
What is Python Lambda Function? Python Tutorial | Edureka
Functions in Python
Variables in python
Python functions
Strings in python
Python Functions
Modules and packages in python

What's hot (20)

PPT
Java awt
PPTX
Classes objects in java
PDF
Python strings
PPTX
List in Python
PPTX
File Handling Python
PPTX
C# classes objects
ODP
PDF
Python course syllabus
PDF
Lesson 02 python keywords and identifiers
PPTX
Python Libraries and Modules
PDF
Python-03| Data types
PDF
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
PPTX
Basics of Object Oriented Programming in Python
ODP
Python Modules
PPTX
Python
PPTX
Collections and its types in C# (with examples)
PDF
C++ Files and Streams
PPTX
Python-Encapsulation.pptx
PPT
Python Control structures
Java awt
Classes objects in java
Python strings
List in Python
File Handling Python
C# classes objects
Python course syllabus
Lesson 02 python keywords and identifiers
Python Libraries and Modules
Python-03| Data types
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Basics of Object Oriented Programming in Python
Python Modules
Python
Collections and its types in C# (with examples)
C++ Files and Streams
Python-Encapsulation.pptx
Python Control structures
Ad

Similar to PYTHON OBJECTS - Copy.pptx (20)

PDF
E-Notes_3720_Content_Document_20250107032323PM.pdf
PPT
Java: Objects and Object References
PPTX
PYTHON PPT.pptx python is very useful for day to day life
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
PPTX
About Python
PPTX
Presentation on python data type
PPTX
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PDF
Python_Unit_1.pdf
PPTX
AI_2nd Lab.pptx
PPTX
Week 2 Lesson Natural Processing Language.pptx
PDF
Lecture20 vector
PPT
py lsfgsdfgdsfgdfsgdsfgdfsfdgfdlecasdf.ppt
PPTX
Javascript Objects Deep Dive
PDF
4. Data Handling computer shcience pdf s
PPT
OOP Principles
PPTX
DAY_1.3.pptx
ODP
Dynamic Python
PDF
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
DOCX
unit 1.docx
PPTX
Object oriented database concepts
E-Notes_3720_Content_Document_20250107032323PM.pdf
Java: Objects and Object References
PYTHON PPT.pptx python is very useful for day to day life
software construction and development week 3 Python lists, tuples, dictionari...
About Python
Presentation on python data type
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
Python_Unit_1.pdf
AI_2nd Lab.pptx
Week 2 Lesson Natural Processing Language.pptx
Lecture20 vector
py lsfgsdfgdsfgdfsgdsfgdfsfdgfdlecasdf.ppt
Javascript Objects Deep Dive
4. Data Handling computer shcience pdf s
OOP Principles
DAY_1.3.pptx
Dynamic Python
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
unit 1.docx
Object oriented database concepts
Ad

Recently uploaded (20)

PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PDF
. Radiology Case Scenariosssssssssssssss
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PPTX
BIOMOLECULES PPT........................
DOCX
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PPTX
neck nodes and dissection types and lymph nodes levels
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
PPT
POSITIONING IN OPERATION THEATRE ROOM.ppt
PDF
HPLC-PPT.docx high performance liquid chromatography
PPTX
TOTAL hIP ARTHROPLASTY Presentation.pptx
PPTX
Microbiology with diagram medical studies .pptx
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
The KM-GBF monitoring framework – status & key messages.pptx
. Radiology Case Scenariosssssssssssssss
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Taita Taveta Laboratory Technician Workshop Presentation.pptx
BIOMOLECULES PPT........................
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
7. General Toxicologyfor clinical phrmacy.pptx
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
neck nodes and dissection types and lymph nodes levels
2. Earth - The Living Planet Module 2ELS
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
Introduction to Fisheries Biotechnology_Lesson 1.pptx
POSITIONING IN OPERATION THEATRE ROOM.ppt
HPLC-PPT.docx high performance liquid chromatography
TOTAL hIP ARTHROPLASTY Presentation.pptx
Microbiology with diagram medical studies .pptx
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...

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.