Data type is very important concept of every programming languages.
Every variables can store data with different data types and each data type has different property.
Python has following data types:
Numeric
Python has three different types of numeric value:
- Integer: It is positive or negative number.
- Float: It is positive or negative number with decimal value.
- Complex: It is a number with imaginary component.
String Type
It is a collection of characters and define string by single quote or double quote.
Boolean
It is defined as TRUE and FALSE same as other languages.
Sequence Type
Python has three types of sequence data types:
- List: It is collection of one or more data items. It can be defined using square brackets [a, b, c].
- Tuple: It is collection of one or more data items but defined in parentheses like (a, b, c).
- Range: It is represent the unchangeable sequence of numbers and is mainly used for loop. It is defined as range(start, stop).
Mapping Type
dict: It is a collection of data in key:value pair like {1: “a”, 2:”b”, 3:”c”}.
Set Types
Python has two set types.
- set: Sets are list of unordered and unique elements. A set may be modified.
- frozenset: it is same as sets but it can’t be modified.
Binary Types
The binary types include bytes, bytearray, memoryview.