Python Highlights | Python Numbers

Pybeginner
By -
0


Python supports integers, floating point numbers, and complex numbers.

► int

► float

► complex


Integers are zero, positive or negative whole numbers without a fractional part and having unlimited precision.

e.g. 0, 100, -10


A float number is a number that is represented in decimals.

e.g. 0.5, 100.2


A complex number is expressed as a sum of a real part and an imaginary part.

e.g. 3 + 1j


We can use the type( ) function to know which class a variable or value belongs to and the isinstance( ) function to check if it belongs to a specific class. The good thing is that we can also convert these numbers into another type whenever we require them. If we wanna know the type of the number then for that we can use the type( ) function which returns the type of the number.

 



Tags:

Post a Comment

0Comments

Post a Comment (0)