Showing posts with the label Python - Data Types

Python Programming Language - Data Types

The variable stores data of one of the data types. There are many different data types in Python.  Data types in Python can be classified into mutable and immutable.  Mutable and immutable data types   When we assign a new value to an immutable object, Python does not overwrite it, but creates a new object with the same name. To verify this, just check the id - a unique number that is assigned to each object in Python: num = 10 print( "id of num: " , id(num)) num += 3 print( "id of num: " , id(num)) Console output: id of num:  140729805956168 id of num:  140729805956264 When we add 3 to a variable num, a new object with the same name is created in its place. Note: at the first output, the id is 140729805956168, and after performing the addition operation it is 140729805956264. But In the below code, the list identifier users does not change, because lists in Python are mutable objects: users = [ 'Carl' , 'Rick' , 'Morgan' ] print( "id of