1. 使用 ` ` 运算符:
```python
number = 5
square = number 2
print(square) 输出:25
2. 使用 `math.pow()` 函数(需要导入 `math` 模块):
```python
import math
number = 8
square = math.pow(number, 2)
print(square) 输出:64
3. 使用内置的 `pow()` 函数:
```python
number = 10
square = pow(number, 2)
print(square) 输出:100
4. 使用 `numpy.square()` 函数(如果使用 `NumPy` 库):
```python
import numpy as np
number = 5
square = np.square(number)
以上是计算平方的几种常见方法。您可以根据需要选择合适的方法