Python Data type

A Data type is a classification of data/value stored in a variable. It represent the type of data stored into a variable or memory. Data type may be mathematical, relational or logical operations.

Some datatypes are available in Python language are called as Built-in datatypes. And some datatypes which are created by the programmers are called user-defined datatypes.

Built-in Datatypes in Python:

  • None Type: false
  • Numeric Types: int, float, complex
  • Sequence Types: list, tuple, complex
  • Mapping Types: dict
  • Set Types: set, frozenset

None Type

In Python, none type datatype represents an object having no any value. In others language like Java, it is called “NULL”.

In Boolean expression, it is expressed as “FALSE”.

Numeric Types

In Numeric types datatype, there are three sub types divided:

  • Int
  • Float
  • Complex

Int Datatype: Int datatype represent a variable having integer type number. Integer type datatype variable cannot have decimal or fraction type value.
Example – 100, -20, 0, 9393939 etc. are treated as integer numbers.

In python, there is no size limit for int datatype. One can store very large integer numbers.

Float Datatype: Float datatype represents a variable having floating point numbers. It means a variable should have decimal point values.

Example- 3.3, -5.44, 350.50 etc. are treated as floating point numbers.

Complex Datatype: Complex datatype represented as a+bj.
Here, a and b are real part of the number. And j is the imaginary part of the number.

Example – 3+5j, -2-4j, 0.3+0.6j are all treated as complex datatype numbers.

Sequence Types

Sequence types datatype represents such type of variable having a collection of elements or items. In python, there are six types of sequences in python:

  • Str
  • Bytes
  • Bytesarray
  • List
  • Tuple
  • Range

Str Datatype: In Python, str represents string datatype. A string is represented by a group of characters. Strings are always enclosed within either single quotes(”) or double quotes(“”).

For example - 
str =  "Hello World"
str = 'Hello World'

Here, str having values which are enclosed within single and double quotes, both are valid.

We can also use triple single(”’) or triple double quotes(“””) to embed a string inside another string.

For example - 
str = """Please explore 'Share Query' to learn Python"""


str = '''Please explore 'Share Query' to learn Python'''

Byte Datatype

Trending Topics