1. 使用 ` ` 操作符:
```python
x = 2
result = x 2
print(result) 输出:4
2. 使用 `pow()` 函数:
```python
x = 2
result = pow(x, 2)
print(result) 输出:4
3. 使用 `math.sqrt()` 函数计算平方根(注意这是计算平方根,不是平方):
```python
import math
x = 16
sqrt_x = math.sqrt(x)
print("数字", x, "的平方根为", sqrt_x) 输出:数字 16 的平方根为 4
请根据你的需求选择合适的方法