Element-wise Product
Multiply corresponding values of two equal-sized lists. Students pair indexes, append products, and distinguish element-wise multiplication from list repetition.
1# Take arrays2n = int(input("Enter array size: "))3arr1 = []4for i in range(n):5 arr1.append(int(input(f"Array1 element {i+1}: ")))67arr2 = []8for i in range(n):9 arr2.append(int(input(f"Array2 element {i+1}: ")))1011# Element-wise product12product_arr = []13for i in range(n):14 product_arr.append(arr1[i] * arr2[i])1516print(f"Product array: {product_arr}")
Output
Enter array size: 3 Array1 element 1: 2 Array1 element 2: 3 Array1 element 3: 4 Array2 element 1: 5 Array2 element 2: 6 Array2 element 3: 7 Product array: [10, 18, 28]
In this one
- Multiply corresponding entries
- Keep products separate
- Distinguish from a dot product
How it works
- 1
Read equally sized lists.
- 2
Append the product of each indexed pair.
- 3
Print product_arr without summing its entries.
Edge cases
What happens for n = 0?
What happens for n = 0?
The product list is empty.
Are the products added afterward?
Are the products added afterward?
No. Each product remains a separate result entry.
What's going on
The same n controls input for both lists. The result loop multiplies arr1[i] by arr2[i] and appends that product.
For [2, 3] and [4, 5], the result is [8, 15]. This is neither a Cartesian product nor a dot-product total. The new list preserves positional pairing, and either zero factor makes its particular product zero.
What happens for n = 0? The product list is empty.
Are the products added afterward? No. Each product remains a separate result entry.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
What is paired with arr1[i]?
Pick an answer to check it.
Question 2
What happens for n = 0?
Pick an answer to check it.
Questions people ask
What happens for n = 0?
The product list is empty.
Are the products added afterward?
No. Each product remains a separate result entry.
What is paired with arr1[i]?
arr2[i].
๐Related Content
- ๐
Phase 4 - Learn Concepts
Review Phase 4 concepts and explanations
- ๐
Phase 4 - Quiz
Test your Phase 4 understanding with quiz questions
- ๐ป
Phase 4 - All Practice Problems
Explore all practice problems for Phase 4
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum