Blog

python tutorials and learn python

Created with Sketch.

Summary of Datatypes in Python 3

Datatype Description Is Immutable? Example Int We can use to represent the whole/integral numbers Immutable >>> a=10 >>> type(a) <class ‘int’> Float We can use to represent the decimal/floating point numbers Immutable >> b=10.5 >>> type(b) <class ‘float’> Complex We can use to represent the complex numbers Immutable >> c=10+5j >> type(c) <class ‘complex’> >>>…
Read more

Python dict Data Type (PYTHON FUNDAMENTALS)

Python dict Data Type If we want to represent a group of values as key-value pairs then we should go for dict data type. Eg: d = {101:’durga’,102:’ravi’,103:’shiva’} Duplicate keys are not allowed but values can be duplicated. If we are trying to insert an entry with the duplicate key then old value will be…
Read more

Python frozenset Data Type (PYTHON FUNDAMENTALS)

It is exactly the same as set except that it is immutable.  Hence we cannot use add or remove functions.

Python set Data Type (PYTHON FUNDAMENTALS)

Python set Data Type: If we want to represent a group of values without duplicates where the order is not important then we should go for set Data Type.1) Insertion order is not preserved2) Duplicates are not allowed3) Heterogeneous objects are allowed4) Index concept is not applicable5) It is a mutable collection6) Growable in nature…
Read more

Python Range Data Type (PYTHON FUNDAMENTALS)

Python Range Data Type  range Data Type represents a sequence of numbers.  The elements present in the range Data type are not modifiable. i.e range Data type is immutable. Form-1: range(10)generate numbers from 0 to 9 Eg: r = range(10)for i in r : print(i) —> 0 to 9 Form-2: range(10, 20)generate numbers from 10…
Read more

Python Tuple Data Type (PYTHON FUNDAMENTALS)

Python Tuple Data Type  tuple data type is exactly the same as the list data type except that it is immutable. i.e we cannot change values.  Tuple elements can be represented within parentheses. Eg: Note: tuple is the read-only version of the list.

Python List Data Type (PYTHON FUNDAMENTALS)

Python List Data Type If we want to represent a group of values as a single entity where insertion order required to preserve and duplicates are allowed then we should go for list data type.1) Insertion Order is preserved2) Heterogeneous Objects are allowed3) Duplicates are allowed4) Growable in nature5) Values should be enclosed within square…
Read more

Python byte array Data Type (PYTHON FUNDAMENTALS)

bytearray is exactly same as bytes data type except that its elements can be modified. Eg 2:

Python bytes Data Type

bytes Data Type bytes data type represents a group of byte numbers just like an array. Conclusion 1: The only allowed values for byte data type are 0 to 256. By mistake, if we are trying to provide any other values then we will get a value error. Conclusion 2: Once we create a bytes…
Read more

Python Fundamental Data Types vs Immutability

Python Fundamental Data Types vs Immutability ֍ All Fundamental Data types are immutable. i.e once we create an object,we cannot perform any changes in that object. If we are trying to change then with those changes a new object will be created. This non-changeable behavior is called immutability. ֍ In Python if a new object…
Read more