Immutable Data Type in Python - PowerPoint PPT Presentation

About This Presentation
Title:

Immutable Data Type in Python

Description:

This presentation is here to help you understand about the Immutable Data Type in Python, and it explains its components with programing example. – PowerPoint PPT presentation

Number of Views:36

less

Transcript and Presenter's Notes

Title: Immutable Data Type in Python


1
Data Types in Python
Swipe
2
Immutable Data Type in Python
Note- Immutable can not be changed after
creation. Some immutable types include numeric
data types, strings, bytes, frozen sets, and
tuples.
Numeric Data Types
Immutable Data Types
Strings and Bytes
Frozen Sets
Tuples
3
Numeric Data Types
As you know that integers are immutable Similarl
y, Pythons other built-in numeric data types
such as booleans, floats, complex numbers,
fractions, and decimals are also
immutable! Numeric data types are numbers stored
in database columns Approximate numeric types,
values where the precision needs to be preserved
and the scale can be floating.
4
Strings and Bytes
Textual data in Python is handled with str
objects, more commonly known as strings. They
are immutable sequences of Unicode code points.
Unicode code points can represent a
character. When it comes to storing textual data
though, or sending it on the network, you may
want to encode it, using an appropriate encoding
for the medium which is used The result of an
encoding produces a bytes object, whose syntax
and behavior is similar to that of strings.
5
Frozen Sets
Frozenset objects are quite limited in respect of
their mutable counterpart since they cannot be
changed.
Nevertheless, membership
they test,
still union,
prove very intersection,
effective for and different
operations, and for performance reasons.
6
Tuples
  • The last immutable sequence type were going to
    see is the tuple.
  • A tuple is a sequence of arbitrary Python objects.
    In a tuple, items are separated by commas.
  • These, too, are immutable, as shown in the followi
    ng example

g (1, 3, 5) print(id(g))
,, ,,
g (42, ) print(id(g))
Out 139952252343784 139952253457184
7
Topics for next Post
Object Reusability in Python.
Stay Tuned with
Write a Comment
User Comments (0)
About PowerShow.com