WHAT ARE THE DATA TYPES IN PYTHON?

430 viewsPYTHONPython
0

WHAT ARE THE DATA TYPES IN PYTHON?

Saraswat World Changed status to publish June 14, 2023
0
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.

Categories Data Type Example
Text str x = โ€œBe Happyโ€
Numeric int x = 1
Numeric float x = 3.5
Numeric complex x = 1j
Sequence list x = [โ€œAโ€, โ€œBโ€, โ€œCโ€]
Sequence tuple x = (โ€œAโ€, โ€œBโ€, โ€œCโ€)
Sequence range x = range(6)
Mapping dict x = {โ€œfruitโ€ : โ€œAppleโ€, โ€œPriceโ€ : 200}
Set set x = {โ€œAโ€, โ€œBโ€, โ€œCโ€}
Set frozenset x = frozenset({โ€œAโ€, โ€œBโ€, โ€œCโ€})
Boolean bool x = True
Binary bytes x = bโ€Helloโ€
Binary bytearray x = bytearray(6)
Binary memoryview x = memoryview(bytes(6))
None NoneType x = 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
Ordered Mutable-Changeable Unique elements
List Yes Yes No
Tuple Yes No No
Set No No Yes
Dictionary Yes Yes Yes
Collection Datatypes in Python
Saraswat World Changed status to publish June 14, 2023
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

Ganesh Ji Arti A Tribute to Dilip Kumar