python创建一个全为0的4*4数组和全为1的4*4数组,
时间: 2023-11-17 13:06:15 浏览: 197
创建全为0的4*4数组:
```python
import numpy as np
zero_array = np.zeros((4,4))
print(zero_array)
```
输出:
```
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
```
创建全为1的4*4数组:
```python
import numpy as np
one_array = np.ones((4,4))
print(one_array)
```
输出:
```
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
```
阅读全文