Python Numbers Type

Python numbers are a fundamental data type used to represent numerical values. Python supports three types of numbers: integers, floating-point numbers, and complex numbers. Each type of number has its own characteristics and uses.

Integers

Integers are whole numbers, they can be positive or negative. They can be written in decimal (base 10), binary (base 2), octal (base 8), or hexadecimal (base 16) notation.

1x = 10 # decimal 2y = 0b1010 # binary 3z = 0o12 # octal 4w = 0xA # hexadecimal

Floating-point numbers

Floating-point numbers are numbers with a decimal point. They are used to represent real numbers. They can be written in decimal notation or in scientific notation.

1x = 3.14 2y = 1.5e2

Complex numbers

Complex numbers are numbers with a real and an imaginary component. The real component is represented by a floating-point number and the imaginary component is represented by the letter 'j' or 'J'.

1x = 3 + 4j 2y = 4 - 2j

Python provides a variety of built-in functions and operators for working with numbers, such as mathematical operations, type conversion, and bit manipulation. These functions and operators allow you to perform a wide range of operations on numbers, such as adding, subtracting, multiplying, dividing, and finding the absolute value.