Computer Science, asked by aanshighosh5608, 6 months ago


2. Write a program to store 15 values in Array A and add 5 to each element and store it in
Array B.​

Answers

Answered by Equestriadash
0

The following co‎des have been written using Python.

\tt l\ =\ list()\\for\ i\ in\ range(15):\\{\ \ \ \ \ }n\ =\ int(in put("Enter\ a\ number:\ "))\\{\ \ \ \ \ }l.append(n)\\{\ \ \ \ \ }print()\\import\ numpy\ as\ np\\array\_a\ =\ np.array(l)\\array\_b\ =\ array\_a\ +\ 5\\print(array\_b)

We first assign a list to store the input values and start a loop to obtain the values and insert them into the list. Once that's over, we import a module, \tt numpy [NumPy - Numerical Python], to create the array. We assign the converted-list-to-array to array_a. In array_b, we add array_5 by 5, indicating that each element is increased by 5. The final output is then printed.

Similar questions