1. 使用 `math` 模块中的 `sqrt` 函数:
```python
import math
result = math.sqrt(16)
print(result) 输出:4.0
2. 使用 ` ` 运算符进行幂运算,例如计算平方根:
```python
result = 16 0.5
print(result) 输出:4.0
3. 使用 `cmath` 模块计算复数的平方根:
```python
import cmath
result = cmath.sqrt(-25)
print(result) 输出:5j
4. 使用 `numpy` 模块中的 `sqrt` 函数(如果需要处理数组或矩阵):
```python
import numpy as np
result = np.sqrt(16)
print(result) 输出:4.0
5. 使用 `pow` 函数,通过将指数设置为 `0.5` 来计算平方根:
```python
result = pow(16, 0.5)
print(result) 输出:4.0
请选择适合你需求的方法进行计算