使用numpy.random.rand创建一个10*10的ndarray对象,并打印出最大最小元素。

import numpy as np
a=np.random.rand(10,10)
print(np.max(a))
print(np.min(a))
print(a)
'''
输出为:
0.962061192104585
0.012682301759342152
[[0.11534914 0.5884379  0.43119901 0.05118854 0.65176489 0.88308137
  0.73571071 0.17012149 0.88973416 0.67050488]
 [0.95573358 0.0873741  0.60797374 0.26178789 0.32708553 0.29765766
  0.27003137 0.63050137 0.87385164 0.43969886]
 [0.89093885 0.71762487 0.5034561  0.96206119 0.23803969 0.71505443
  0.72196511 0.62634659 0.27366278 0.6973719 ]
 [0.79670019 0.49296642 0.5546033  0.72624812 0.570847   0.58777556
  0.1866396  0.92669871 0.40855208 0.10576027]
 [0.55141426 0.38716547 0.1270334  0.94446398 0.65677427 0.36880968
  0.8693014  0.7693198  0.54804392 0.14010775]
 [0.0315627  0.13707956 0.35412248 0.13170145 0.6464302  0.25746569
  0.75816591 0.55846938 0.60544948 0.06634258]
 [0.87290049 0.23996223 0.96060323 0.41770004 0.21251022 0.49999077
  0.79891855 0.40053882 0.20293571 0.38148357]
 [0.70100598 0.08318675 0.78394456 0.02932425 0.21929702 0.94319483
  0.53966784 0.79423216 0.10756112 0.72476041]
 [0.51623338 0.78930547 0.4993121  0.40999929 0.37429133 0.79092677
  0.48993243 0.06720893 0.59982202 0.44322784]
 [0.0126823  0.63841279 0.46205563 0.36115944 0.70475797 0.20244854
  0.84109233 0.8057231  0.15785316 0.62928203]]
'''

你可能感兴趣的:(Python七天实训)