Can we multiply the the whole array elements by single element at a time without using loops??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we multiply the the whole array elements by single element at a time without using loops???

if a=[1,2,3] and multiplying the whole by 3.. then we should obtain a=[3,6,9]

1st Jun 2017, 11:28 AM
hamsa
hamsa - avatar
4 Answers
0
it mean???
1st Jun 2017, 11:31 AM
hamsa
hamsa - avatar
0
There is one more way around it: import numpy a = [1, 2, 3] b = numpy.array(a) print(b * 3) Arrays created using numpy library look just the regular ones, but they have their own class and additional functionality. In this case b is a numpy array and it will behave just like you want it to.
1st Jun 2017, 6:18 PM
Lana
Lana - avatar
0
should we require any header file for it?? and in which programming language we can get it? @Lana
31st Jul 2017, 7:16 AM
hamsa
hamsa - avatar
0
@hamsa The example code is for Python. As far as I know, you don't need to do anything else, if the numpy library is already installed
2nd Aug 2017, 7:22 PM
Lana
Lana - avatar