Python supports integers, floating-point and complex numbers written as:

  1. int
  2. float
  3. complex
Python Numbers

Let’s understand with Example –

x = 10 #int
y = 10.5 #float
z = 10j #complex

Note :- We can check type of value using type() function as shown in code below -

print(type(x)) # Result will be <class 'int'>

int –

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

Example :-

x = 1980

y = 5982342342

z = -8023432

Float –

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

Example :-

x = 10.05

y = 56.888

z = -65.44

X = 23e45

Y = 55.7e100

Z = 132E47

Complex –

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

Example :-

x = 4+6j

y = 6j

z = -6j

One thought on “Python Numbers”

Leave a Reply

Your email address will not be published.