Numbers
Numbers are Immutable objects in Python that cannot change their values. There are three built-in data types for numbers in Python3: - Integer (int
) - Floating-point numbers (float
) - Complex numbers: <real part> + <imaginary part>j
Common Number Functions
Function | Description |
---|---|
int(x) | To convert x to an integer |
float(x) | To convert x to a floating-point number |
abs(x) | The absolute value of x |
cmp(x, y) | -1 if x < y , 0 if x == y , or 1 if x > y |
exp(x) | The exponential of x: e x |
log(x) | The natural logarithm of x, for x > 0 |
pow(x, y) | The value of x**y |
sqrt(x) | The square root of x for x > 0 |