Let there be two Numpy arrays, n1 and n2.
n1=[45,60]
n2=[55,40]
Which of the following gives you the correct solution for vertical addition of the NumPy array values?
Answers
n3 which is the verticals sum of n1 and n2 first define it.
Answer:
import numpy as np
a = np.array([[45, 60], [55, 40]])
arr1 = np.sort(a, axis = 0)
print ("nOn the first axis : \n", arr1)
a = np.array([[45, 60], [55, 40]])
arr2 = np.sort(a, axis = -1)
print ("\nOn the first axis : \n", arr2)
a = np.array([[45, 60], [55, 40]])
arr1 = np.sort(a, axis = None)
print ("\nOn the none axis : \n", arr1)
output:
On the first axis :
[[45 60]
[55 40]]
On the first axis :
[[40 45]
[ 55 60]]
On the none axis :
[ 40 45 55 60]
Explanation:
A general-purpose toolkit for processing arrays called NumPy offers capabilities for working with n-dimensional arrays. It offers a variety of computational tools, including procedures for linear algebra and complete mathematical functions. With NumPy, you can have Python's flexibility and well-optimized, compiled C code's speed. For programmers of all backgrounds, it is incredibly accessible and productive because to its simple syntax.
The Python package NumPy is used to manipulate arrays. Additionally, it has matrices, fourier transform, and functions for working in the area of linear algebra.
The syntax of NumPy is at once concise, strong, and expressive. It enables users to manage data in higher dimensional arrays, matrices, and vectors.
#SPJ2