Python Numbers - int, float, and complex Type

« Previous Tutorial Next Tutorial »

Numeric types in Python are used to store numeric values. The three numeric types in Python, are:

  1. int
  2. float
  3. complex

Note - The type() function is used to find the type of a value/variable. For example:

x = 45
y = 34.54
z = 12j


The output is:

<class 'int'>
<class 'float'>
<class 'complex'>

Python int Type

Any whole number is considered as of int type. For example, 12, 1, 0, -1345431234, 23456765432134565432 etc.

Python float Type

Any number with decimal (except the complex number) is considered as of float type. For example, 1.9, 2.0, -4253464.2433 etc.

Note - Numbers like 781e4, 23E3, -3542.6e10 etc. are also considered as floating-point number, where e or E indicates to the power of 10. Therefore these numbers are of float type.

The number 781e4 is equal to 7810000.0. Similarly the number -3542.6e5 is equal to -354260000.0.

Note - Number in the form of 123e32 can also be called as scientific number.

Python complex Type

Any number with imaginary part is considered as complex type. For example, 23+6j, 10j, -32j etc.

Python Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.