WHAT ARE THE DATA TYPES IN PYTHON

DATA TYPES IN PYTHON

Python has the following data types built-in by default. Variable can store data of different types as per requirements.

CategoriesData TypeExample
Textstrx = “Be Happy”
Numericintx = 1
Numericfloatx = 3.5
Numericcomplexx = 1j
Sequencelistx = [“A”, “B”, “C”]
Sequencetuplex = (“A”, “B”, “C”)
Sequencerangex = range(6)
Mappingdictx = {“fruit” : “Apple”, “Price” : 200}
Setsetx = {“A”, “B”, “C”}
Setfrozensetx = frozenset({“A”, “B”, “C”})
Booleanboolx = True
Binarybytesx = b”Hello”
Binarybytearrayx = bytearray(6)
Binarymemoryviewx = memoryview(bytes(6))
NoneNoneTypex = None
PYTHON DATA TYPES

To get the data type of any object we can use the type() function in Python.

Example-

print (type(x))

Python Collections (Arrays)

There are four collection data types in the Python programming language:

List

List is a collection which is ordered and changeable. Allows duplicate members.

Tuple

Tuple is a collection which is ordered and unchangeable. Allows duplicate members.

Set

Set is a collection which is unordered, unchangeable, and unindexed. No duplicate members.

Set items are unchangeable, but you can remove and/or add items.

Dictionary

is a collection which is ordered and changeable. No duplicate members.

Properties of collection datatypes in python
Collection
DataTypes
OrderedMutable-ChangeableUnique elements
ListYesYesNo
TupleYesNoNo
SetNoNoYes
DictionaryYesYesYes
Collection Datatypes in Python

Leave a Reply

Your email address will not be published. Required fields are marked *