Python Numbers

The numbers in python can be represented by :

int

float

complex

The Numeric type variable in python created when you assign value to them.

We can verify the type of any object in python, use the type() function.

Examples

Int:-

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

Examples

Example of int

Float:-

Float numbers, positive or negative, containing one or more decimals.

Examples

Example of float

Complex:-

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

Examples

Example of complex number

Type Conversion

You can convert one number to another using int(), float() and complex().

Examples

Type conversion

Note:- Complex numbers can’t convert to integer or float numbers.

Random Numbers

Python does not have a random() function to make a random number, but python has a built-in module called random that can be used to make the random number.

Examples

Example of random number

Conclusion:- The numbers can convert from one number to another number using int(), float(), complex(). The complex number can’t convert to int or float.

Leave a comment