python math库
时间: 2023-09-15 21:20:02 浏览: 76
The math module in Python provides various mathematical functions and constants. Some of the functions and constants provided by the math module are:
1. Trigonometric functions: sin(), cos(), tan(), asin(), acos(), atan()
2. Exponential and logarithmic functions: exp(), log(), log10()
3. Power and square root functions: pow(), sqrt()
4. Constants: pi, e
Example:
```python
import math
# Finding the square root of a number
print(math.sqrt(25)) # Output: 5.0
# Finding the value of pi
print(math.pi) # Output: 3.141592653589793
# Finding the sine of an angle
print(math.sin(math.pi/2)) # Output: 1.0
# Finding the exponential value of a number
print(math.exp(3)) # Output: 20.085536923187668
```
Note: The math module is part of the standard Python library and does not require any additional installation.
阅读全文