Inner and Outer in Python HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Inner and Outer in Python HackerRank Solution. This problem is a part of the HackerRank Python Programming Series.

Inner and Outer in Python HackerRank Solution
Inner and Outer in Python HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Inner and Outer in Python HackerRank Solutions

Problem

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 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 product.

Input Format :

The first line contains the space separated elements of array A.
The second line contains the space separated elements of array B.  

Output Format :

First, print the inner product.
Second, print the outer product.

Sample Input :

0 1
2 3

Sample Output :

3
[[0 0]
 [2 3]]

Inner and Outer in Python HackerRank Solutions

import numpy
A = numpy.array(input().split(), int)
B = numpy.array(input().split(), int)
print(numpy.inner(A, B), numpy.outer(A, B), sep='\n')

Disclaimer: The above Problem (Inner and Outer in Python) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Polynomials in Python HackerRank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *