0
0
NumPydata~15 mins

Matrix multiplication with @ operator in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Matrix multiplication with @ operator
📖 Scenario: Imagine you work in a small company that analyzes sales data. You have two tables of numbers: one shows sales by product and month, and the other shows the price of each product. You want to find the total sales revenue for each month by multiplying these tables.
🎯 Goal: You will create two matrices using numpy, then multiply them using the @ operator to find total sales revenue per month.
📋 What You'll Learn
Create two numpy arrays with exact values
Use a variable to store the result of matrix multiplication
Use the @ operator for matrix multiplication
Print the resulting matrix
💡 Why This Matters
🌍 Real World
Matrix multiplication is used in many fields like sales analysis, computer graphics, and machine learning to combine data efficiently.
💼 Career
Knowing how to multiply matrices with numpy is a key skill for data scientists and analysts working with numerical data.
Progress0 / 4 steps
1
Create sales and price matrices
Import numpy as np. Create a numpy array called sales with these exact values: [[10, 20, 30], [5, 10, 25]]. Create another numpy array called prices with these exact values: [[2], [3], [4]].
NumPy
Need a hint?

Use np.array() to create matrices with the exact numbers given.

2
Create a variable for total revenue
Create a variable called total_revenue and set it to None as a placeholder.
NumPy
Need a hint?

Just create the variable total_revenue and assign None for now.

3
Multiply matrices using @ operator
Use the @ operator to multiply sales by prices. Store the result in the variable total_revenue.
NumPy
Need a hint?

Use total_revenue = sales @ prices to multiply the matrices.

4
Print the total revenue matrix
Print the variable total_revenue to display the result of the matrix multiplication.
NumPy
Need a hint?

Use print(total_revenue) to show the final matrix.