Math operations
Python hosting: PythonAnywhere — host, run and code Python in the cloud. Free tier available.
Python has support for both mathematical operations and functions.
Mathematical operations An overview of operations:
| Operation | Result | |
|---|---|---|
| x + y | sum of x and y. | |
| x * y | multiplication of x and y. | |
| x - y | difference of x and y. | |
| x / y | division of x by y. | |
| x % y | remainder of x/y | |
| x ** y | x to the power of y | |
| abs(x) | absolute value of x | |
| sqrt(x) | square root of x |
| Function | Returns | Example |
|---|---|---|
| abs(x) | Returns the absolute value of x. |
|
| cmp(x,y) |
Returns -1 if x < y Returns 0 if x equals to y Returns 1 if x > y. |
|
| exp(x) | Returns the exponential of x |
|
| log(x) | The natural logarithm of x |
|
| log10(x) | The base-10 logarithm of x |
|
| pow(x,y) | The result of x**y |
|
| sqrt(x) | The square root of x |
|