1. Integers (int):
Integers represent whole numbers without a fractional or decimal part.
2. Floating-Point Numbers (float):
Floating-point numbers represent real numbers with a decimal or fractional part. They use a decimal point to differentiate from integers.
3. Complex Numbers (complex):
Complex numbers consist of a real part and an imaginary part, denoted by "j" or "J."
4. Number Conversions:
You can convert between number types using constructors, such as int()
, float()
, and complex()
.
5. Basic Number Operations:
Python supports standard arithmetic operations, including addition, subtraction, multiplication, division, and modulus.
6. Exponentiation:
You can raise a number to a power using the **
operator.
7. Math Functions:
Python's math
module provides a wide range of mathematical functions for more advanced numerical calculations.
8. Number Comparisons:
You can compare numbers using comparison operators, such as ==
, <
, >
, <=
, and >=
.
9. Number Type Checking:
You can check the type of a variable using the isinstance()
function.
10. Type Conversion:
You can convert numbers to strings using the str()
function.
11. Infinite and NaN:
Python provides special constants for positive and negative infinity, as well as for "Not-a-Number" (NaN).
Python's support for various numeric types and operations makes it a versatile language for mathematical and scientific computing. You can perform a wide range of calculations, including basic arithmetic, advanced mathematical functions, and complex number operations using Python's built-in capabilities and libraries.