title-img


Inner and Outer python

inner The 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 two arrays. import numpy A = numpy.array([0, 1]) B = numpy.array([3, 4]) print numpy.outer(A, B) #Output : [[0 0] # [3 4]] Task You are given two arrays: A and B. Your task is to compute their inner and outer

View Solution →

Polynomials python

poly The 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] roots The roots tool returns the roots of a polynomial with the given coefficients. print numpy.roots([1, 0, -1]) #Output : [-1. 1.] polyint The polyint tool returns an antiderivative (indefinite integral) of a polynomial. print numpy.polyint([1, 1, 1]) #Output : [ 0.33333333 0.5

View Solution →

Linear Algebra python

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 array. print numpy.linalg.det([[1 , 2], [2, 1]]) #Output : -3.0 linalg.eig The linalg.eig computes the eigenvalues and right eigenvectors of a square array. vals, vecs = numpy.linalg.eig([[1 , 2], [2, 1]]) print vals #Output : [ 3. -1.]

View Solution →

Words Score Python

In this challenge, the task is to debug the existing code to successfully execute all provided test files. Consider that vowels in the alphabet are a, e, i, o, u and y. Function score_words takes a list of lowercase words as an argument and returns a score as follows: The score of a single word is 2 if the word contains an even number of vowels. Otherwise, the score of this word is . The score for the whole list of words is the sum of scores of all words in the list. Debug the given

View Solution →

Default Arguments Python

In this challenge, the task is to debug the existing code to successfully execute all provided test files. Python supports a useful concept of default argument values. For each keyword argument of a function, we can assign a default value which is going to be used as the value of said argument if the function is called without it. For example, consider the following increment function: def increment_by(n, increment=1): return n + increment The functions works like this: >>> increm

View Solution →