Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Creating a Matrix Using NumPy Arrays

If you're in the position where your work requires you to work with n-dimensional arrays (matrices), then `numpy` will be a staple tool in your toolbelt. Knowing how to create matrices using arrays is a fundamental skill for working with `numpy`. In this hands-on lab, we go through the process of installing `numpy`, building up some arrays, and combining them to create a matrix. To feel comfortable completing this lab, you'll want to know how to do the following: - Using NumPy arrays. Watch the "What are NumPy Arrays?" video from the [Using Python's Math, Science, and Engineering Libraries](https://linuxacademy.com/cp/modules/view/id/62) course. - Using NumPy matrices. Watch the "Reshaping a NumPy Array into a Matrix" video from the [Using Python's Math, Science, and Engineering Libraries](https://linuxacademy.com/cp/modules/view/id/621) course.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 19, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Install NumPy

    Before we can start working with NumPy, we'll need to make sure that we have it installed. Utilize pip to install the numpy package.

  2. Challenge

    Creating NumPy Arrays for Each Store's Sales and Item Prices

    Since we have the sales numbers for each item from each store, we can create an array for each store's sales that can later be used to make calculations. We need to make sure that we're putting the sales numbers for each item in the same position for each of our stores' arrays. Create a 4 item array for each store, placing the number of sales for each item in the order of pens, notebooks, staplers, and backpacks.

  3. Challenge

    Create the Sales and Prices Matrix

    Because we have 4 different items, each stores' sales are stored as a 4 item, one-dimensional array, or a 1x4 matrix. We can use matrix multiplication to calculate the revenue for a store by multiplying that array with a 4x1 matrix where each row is the price for the corresponding column item in the sales arrays. Combine all of our sales variables into a single 4x4 matrix so that we can calculate the revenue for all of the stores at the same time, and create a 4x1 prices matrix that has the prices list from top to bottom for pen, notebook, stapler, and backpack.

  4. Challenge

    Calculate Store Revenues and Total Revenue

    Calculate the dot product of these two matrices to get the revenue for each store and then utilize those values to calculate the total revenue.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight