Python Numbers

In Python, there are three main numeric types, each serving different purposes for representing numbers:

  • int (Integer):
    This type represents whole numbers without a decimal point. It can be positive, negative, or zero. Python integers are of unlimited length, meaning they can grow as large as your memory allows.
    Example: x = 100

Do it

  • float (Floating-Point):
    This type is used for real numbers that have a decimal point. It supports fractional values and scientific notation.
    Example: pi = 3.14159

Do it

  • complex (Complex Number):
    This type is used to represent complex numbers, which have a real part and an imaginary part. It is written as a + bj, where a is the real part and b is the imaginary part.
    Example: z = 2 + 3j

Do it

These numeric types are foundational in Python for performing mathematical computations, simulations, and data analysis.