Posts

Showing posts from December, 2019

Mutable and Immutable Objects

Image
Every thing in python is object. We have to understand all the data represented in python is by object. This object can be immutable or mutable. Immutable Objects are those which can't be changed . Ex:- Int, Float, Complex, String, Tuple, Frozen set. [note: immutable version of set], bytes. Mutable Objects are :- List, Dict, Set, Byte array etc. Immutable Ex:- my_yuple = (10, 20, 30) print(my_yuple) output (10, 20, 30) continue... my_yuple = (10, 20, 30) my_yuple[0] = 40  - - - We are trying to change the first position data. print(my_yuple) output: File "test.py", line 3, in < module > my_yuple[0] = 40 TypeError: 'tuple' object does not support item assignment

Everything is an Object in Python Programming - Data Types !!!

Image
What is a data type in Python? Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. Text Type: str Numeric Types: int , float , complex Sequence Types: list , tuple , range Mapping Type: dict Set Types: set , frozenset Boolean Type: bool Binary Types: bytes , bytearray , memoryview