Fall 1
Code: Select all
import numpy as np
np.random.seed(2)
array = np.random.random((3,1))
print('Printing array : \n', array)
print('printing array - 1 : \n',array-1)
< /code>
Output :
Printing array :
[[0.4359949 ]
[0.02592623]
[0.54966248]]
printing array - 1 :
[[-0.5640051 ]
[-0.97407377]
[-0.45033752]]
< /code>
This is ok as 1 is subtracted from each element
[b]Case 2[/b]
print('Printing array : \n', np.random.random ((3,1))-1)
Ausgabe:
Code: Select all
Printing array :
[[-0.56467761]
[-0.5796322 ]
[-0.66966518]]
< /code>
Whay are the two outputs different? np.random.random ((3,1)