Python Data Types

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:

  1. Integer: It is positive or negative number.
  2. Float: It is positive or negative number with decimal value.
  3. 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:

  1. List: It is collection of one or more data items. It can be defined using square brackets [a, b, c].
  2. Tuple: It is collection of one or more data items but defined in parentheses like (a, b, c).
  3. 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.

  1. set: Sets are list of unordered and unique elements. A set may be modified.
  2. frozenset: it is same as sets but it can’t be modified.
Binary Types

The binary types include bytes, bytearray, memoryview.