Python has a built-in math module that provides a set of functions for mathematical operations. Here are some commonly used math methods in Python:
abs(): Returns the absolute value of a number.
ceil(): Returns the smallest integer greater than or equal to a number.
floor(): Returns the largest integer less than or equal to a number.
round(): Returns the nearest integer to a number.
sqrt(): Returns the square root of a number.
pow(): Returns the value of a number raised to a specified power.
log(): Returns the natural logarithm of a number.
log10(): Returns the base-10 logarithm of a number.
exp(): Returns the value of e raised to the power of a specified number.
cos(): Returns the cosine of a number in radians.
sin(): Returns the sine of a number in radians.
tan(): Returns the tangent of a number in radians.
acos(): Returns the inverse cosine of a number in radians.
asin(): Returns the inverse sine of a number in radians.
atan(): Returns the inverse tangent of a number in radians.
Here's an example of using some of these methods:
This will output:
5
4
3
3
4.0
256
2.302585092994046
1.0
7.3890560989306495
0.7071067811865476
0.7071067811865475
0.9999999999999999
0.7853981633974484
0.7853981633974483
0.7853981633974483