Entered the values of the array a = asarray(input()) . How now to turn to any element? And how to multiply all the elements of the array?
- Where exactly is your difficulty? That does not work? - MaxU
- Found how to enter values. And now how to multiply all the elements of the array? - Roman Oaks
- What do you mean by "multiply all the elements of the array"? Give an example of the input data in the question and what you expect to get at the output - MaxU
- There is an array [1, 2, 3, 4], you need to multiply its elements. Those. 1 * 2 * 3 * 4 - Roman Oaks
|
1 answer
Entered the values of the array a = asarray (input ()). How now to turn to any element?
you entered one line
In [337]: a = np.asarray(input()) 1 2 3 4 In [338]: a Out[338]: array('1 2 3 4', dtype='<U7') if you need to break it into numbers:
In [341]: a = np.array(input().split()).astype(int) 1 2 3 4 In [342]: a Out[342]: array([1, 2, 3, 4]) In [343]: a.dtype Out[343]: dtype('int32') How to multiply all the elements of an array?
In [336]: a.prod() Out[336]: 24 - Thanks, very helpful. - Roman Oaks
|