fbpx

Numbers Copy

The values stored by Number data types are Numeric values. Number objects are only valid when they are assigned values. For example:
var1=10
var2=50
In Python, there are four types of numerical types, i.e. int (signed integers), float (floating point real values) and complex (complex numbers).

Int

Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.

Example:

x = 1
y = 35656222554887711
z = -3255522

print(type(x))
print(type(y))
print(type(z))

Output:

<class ‘int’>
<class ‘int’>
<class ‘int’>

Float

Float, or “floating point number” is a number, positive or negative, containing one or more decimals. Float can also be scientific numbers with an “e” to indicate the power of 10.

Example:

x = 1.10
y = 1.0
z = -35.59

print(type(x))
print(type(y))
print(type(z))

Output:

<class ‘float’>
<class ‘float’>
<class ‘float’>

Complex

Complex numbers are written with a “j” as the imaginary part.

Example:

x = 3+5j
y = 5j
z = -5j

print(type(x))
print(type(y))
print(type(z))

Output:

<class ‘complex’>
<class ‘complex’>
<class ‘complex’>