Python Data Types

Vipin | Sun, 07 Jun, 2020 | 188

In Python Data types can be broadly categorized into five different types, listed as follows:

  • Numbers
  • String
  • Tuples
  • List
  • Dictionary

Numeric data types or numbers

There are generally four numeric data types in Python. They areintegers, long integers, floating point numbers, and complex numbers

Integers and long integers

  • Integers include zero, all of the positive whole numbers, and all of the negative whole numbers.
  • The int or integer data type ranges from -231 to (231-1); the leading minus sign shows the negative values. Beyond these ranges, the interpreter will add L to indicate a long integers.


a = 10
b = 30
c = 40

Floating point numbers

Numbers with certain places after the decimal point are referred to as floating point numbers in the programming language:

  • The floating point number type ranges approximately from -10308 to 10308 and has 16 digits of precision.
  • There are two ways to write a floating point number. It can be written using ordinary decimal notation or scientific notation. Scientific notation is often useful for mentioning very large numbers.


a = 20.45
b = 45.099
c = 767.88788

Complex numbers

A complex number has both real and imaginary parts, and Python allows you to specify this data type in a very easy and convenient way.


<variable_name> = complex(x,y)


<variable_name> =x+yj

Here, x is the real part and y is the imaginary part. Here, j plays the role of iota.


num = complex(3,5)

# or

num = 3+5j

Boolean data type

A Boolean data type generally has only two values 'True' or 'False'.

Boolean data type is a sub type of integers.


<variable_name> = <'True' or 'False'>


a = True

b = False

Boolean data types can be referred to as an on and off switch, which has only two values to chose from.

String data types

A Python string is a contiguous sequence of Unicode characters.

Single quotes or double quotes can be used to denote a string. For multiline string representation, ''' or "' can be used.


<variable_name> = <String Sequence>


my_str1 = "HelloWorld"

my_str2 = ''    

my_str3 = '''
          This is multiline String


Leave a comment