Piling Up in python – HackerRank Solution
There is a horizontal row of n cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow…
There is a horizontal row of n cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow…
The NumPy module also comes with a number of built-in routines for linear algebra calculations. These can be found in the sub-module linalg. linalg.det The linalg.det tool computes the determinant of an…
PolyThe poly tool returns the coefficients of a polynomial with the given sequence of roots. print numpy.poly([-1, 1, 1, 10]) #Output : [ 1 -11 9 11 -10] rootsThe roots…
innerThe inner tool returns the inner product of two arrays. import numpy A = numpy.array([0, 1]) B = numpy.array([3, 4]) print numpy.inner(A, B) #Output : 4 outer The outer tool returns the outer product of…
dotThe dot tool returns the dot product of two arrays. import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print numpy.dot(A, B) #Output : 11…
meanThe mean tool computes the arithmetic mean along the specified axis. import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.mean(my_array, axis = 0) #Output : [ 2.…
MinThe tool min returns the minimum value along a given axis. import numpy my_array = numpy.array([[2, 5], [3, 7], [1, 3], [4, 0]]) print numpy.min(my_array, axis = 0) #Output :…
Sum The sum tool returns the sum of array elements over a given axis. import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.sum(my_array, axis = 0) #Output :…
floorThe tool floor returns the floor of the input element-wise.The floor of x is the largest integer i where i <= x. import numpy my_array = numpy.array([1.1, 2.2, 3.3, 4.4,…
Basic mathematical functions operate element-wise on arrays. They are available both as operator overloads and as functions in the NumPy module. import numpy a = numpy.array([1,2,3,4], float) b = numpy.array([5,6,7,8],…
identity :The identity tool returns an identity array. An identity array is a square matrix with all the main diagonal elements as 1 and the rest as 0. The default…
zerosThe zeros tool returns a new array with a given shape and type filled with 0’s. import numpy print numpy.zeros((1,2)) #Default type is float #Output : [[ 0. 0.]] print…