Recall & Review
beginner
What does the numpy
outer() function do?It computes the outer product of two arrays. This means it multiplies each element of the first array by each element of the second array, creating a matrix.
Click to reveal answer
beginner
How is the shape of the output array from
numpy.outer(a, b) determined?The output shape is (
len(a), len(b)). Each element in a is multiplied by each element in b, forming a 2D array.Click to reveal answer
beginner
Example: What is the result of
numpy.outer([1, 2], [3, 4])?The result is a 2x2 array:<br>
[[3, 4],<br> [6, 8]]<br>Because 1*3=3, 1*4=4, 2*3=6, 2*4=8.Click to reveal answer
intermediate
Can
numpy.outer() work with multi-dimensional arrays?Yes, but it first flattens the input arrays to 1D before computing the outer product.
Click to reveal answer
beginner
Why is
numpy.outer() useful in real life?It helps in tasks like creating grids of values, computing pairwise products, or building matrices for physics and engineering problems.
Click to reveal answer
What is the shape of the output from
numpy.outer([1, 2, 3], [4, 5])?✗ Incorrect
The output shape is (length of first array, length of second array), so (3, 2).
What does
numpy.outer() multiply?✗ Incorrect
It multiplies every element of the first array by every element of the second array.
If you input 2D arrays into
numpy.outer(), what happens first?✗ Incorrect
Numpy flattens multi-dimensional arrays to 1D before computing the outer product.
Which of these is a practical use of
numpy.outer()?✗ Incorrect
Creating multiplication tables is a classic example of using outer products.
What will
numpy.outer([2], [3, 4]) return?✗ Incorrect
2 multiplied by 3 and 4 gives [6, 8] in a 1x2 array.
Explain in your own words what
numpy.outer() does and give a simple example.Think about how you multiply numbers in a multiplication table.
You got /3 concepts.
Describe how
numpy.outer() handles multi-dimensional arrays and why this might be useful.Consider what happens if you have a matrix but want to treat it as a list of numbers.
You got /3 concepts.