Data Types in Python
Swipe
Immutable Data Type in Python
Immutable
Data Types
Numeric Data Types
Strings and Bytes
Frozen Sets
Tuples
Note:-
Immutable can not be changed after creation. Some
immutable types include numeric data types, strings, bytes,
frozen sets, and tuples.
As you know that integers are immutable;
Similarly, Python’s 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.
Numeric Data Types
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.
Strings and Bytes
Frozenset objects are quite limited in respect of their
mutable counterpart since they cannot be changed.
Nevertheless, they still prove very effective for
membership test, union, intersection, and different
operations, and for performance reasons.
Frozen Sets
The last immutable sequence type we’re 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 following
example:
g = (1, 3, 5)
print(id(g))
g = (42, )
print(id(g))
[Out:]
139952252343784
139952253457184
Tuples
,, ,,
Object Reusability in Python.
Stay Tuned with
Topics for next Post

Immutable data type in python

  • 1.
    Data Types inPython Swipe
  • 2.
    Immutable Data Typein Python Immutable Data Types Numeric Data Types Strings and Bytes Frozen Sets Tuples Note:- Immutable can not be changed after creation. Some immutable types include numeric data types, strings, bytes, frozen sets, and tuples.
  • 3.
    As you knowthat integers are immutable; Similarly, Python’s 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. Numeric Data Types
  • 4.
    Textual data inPython 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. Strings and Bytes
  • 5.
    Frozenset objects arequite limited in respect of their mutable counterpart since they cannot be changed. Nevertheless, they still prove very effective for membership test, union, intersection, and different operations, and for performance reasons. Frozen Sets
  • 6.
    The last immutablesequence type we’re 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 following example: g = (1, 3, 5) print(id(g)) g = (42, ) print(id(g)) [Out:] 139952252343784 139952253457184 Tuples ,, ,,
  • 7.
    Object Reusability inPython. Stay Tuned with Topics for next Post