在jupyter Notebook中编写代码实现:①创建一个3*3并且值从0到8的矩阵,并将其进行转置操作②创建一个10*10的随机数组并找到它的最大值。
时间: 2024-03-12 17:50:01 浏览: 75
好的,以下是对你的问题的回答:
①创建一个3*3并且值从0到8的矩阵,并将其进行转置操作
```python
import numpy as np
# 创建一个3*3的矩阵,值从0到8
arr = np.arange(9).reshape(3, 3)
print(arr)
# 进行转置操作
transpose_arr = arr.T
print(transpose_arr)
```
输出结果:
```
[[0 1 2]
[3 4 5]
[6 7 8]]
[[0 3 6]
[1 4 7]
[2 5 8]]
```
②创建一个10*10的随机数组并找到它的最大值
```python
import numpy as np
# 创建一个10*10的随机数组
arr = np.random.rand(10, 10)
print(arr)
# 找到它的最大值
max_value = arr.max()
print(max_value)
```
输出结果:
```
[[0.7597959 0.46851672 0.24594865 0.57119805 0.39845311 0.14327753
0.72025138 0.53403833 0.61233269 0.37066625]
[0.96397368 0.11167963 0.43296674 0.13887695 0.02220858 0.02521912
0.918105 0.41363545 0.34326776 0.16604649]
[0.63387977 0.03739181 0.57887707 0.37338512 0.41852314 0.62577316
0.45176176 0.47678969 0.9628757 0.7938557 ]
[0.86826667 0.52885463 0.56247398 0.12121147 0.3693662 0.92560892
0.13993448 0.66905004 0.47706802 0.16693502]
[0.66223905 0.67320533 0.27274519 0.60754428 0.28721275 0.57536885
0.17617746 0.66187004 0.94975115 0.1409985 ]
[0.37810453 0.04342358 0.78012304 0.82999921 0.72360968 0.23309987
0.19298258 0.08023444 0.12850189 0.75693478]
[0.61962814 0.74729128 0.29219646 0.4303265 0.9292147 0.28515965
0.01473332 0.12031862 0.06218898 0.80276423]
[0.69162571 0.08155789 0.42524235 0.0170923 0.0349356 0.03961421
0.49492674 0.50119006 0.11595425 0.00460835]
[0.05187541 0.45260682 0.22627355 0.16026609 0.92842368 0.15872202
0.1353397 0.42442091 0.15600446 0.46090633]
[0.65582718 0.39688162 0.96005464 0.52787993 0.21591023 0.83455754
0.87697618 0.47785774 0.19067555 0.57267719]]
0.9639736773369417
```
阅读全文