Python Number Datatypes

aimtocode

DataType Definition

Data types are means to identify the type of data and associated operations for handling it. In python, we need not to define the type of the variable while declaring it. The interpreter implicitly binds the value with its type accordingly.

Data types represent a kind of value which determines what operations can be performed on that given data.


Number DataType

Number data types store numeric values. Number objects are created when you assign a value to them. For example

 
 var1 =1
 var2 =10

You can also delete the reference to a number object by using the del statement. The syntax of the del statement is −

 del var1[,var2[,var3[	,varN]]]]

You can delete a single object or multiple objects by using the del statement. For example −

 del var
 del var_a,var_b

Python supports four different numerical types −

  • 1) int (signed integers like 10, 2, 29, etc.)
  • 2) long (long integers, they can also be represented in octal and hexadecimal like 908090800L, -0x1929292L, etc.)
  • 3) float (floating point real values 1.9, 9.902, 15.2, etc.)
  • 4) complex (complex numbers like 2.14j, 2.0 + 2.3j, etc.)
  • Python allows you to use a lowercase l with long, but it is recommended that you use only an uppercase L to avoid confusion with the number 1. Python displays long integers with an uppercase L.
  • A complex number consists of an ordered pair of real floating-point numbers denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.

Different number format example

int long float complex
10 51924361L 0.0 3.14j
100 -0x19323L 15.20 45.j
-786 0122L -21.9 9.322e-36j


Read Also:


aimtocode