Editor

Shopping Cart Total

Advanced · Write the code · from NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

From the lesson: NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

Linear algebra is the math behind machine learning, computer graphics, physics simulations, and data science. Every time a game rotates a 3D object, a search engine ranks pages, or a neural network makes a prediction, matrix operations are doing the heavy lifting.

Read the lesson

A customer buys quantities [4, 2, 6, 1] of items priced at [2.50, 1.75, 0.99, 12.00]. Use the @ operator to compute the total cost, round it to 2 decimals, and print it.

import numpy as np
quantities = np.array([4, 2, 6, 1])
prices = np.array([2.50, 1.75, 0.99, 12.00])
# Compute and print total cost using @

More NumPy Linear Algebra exercises

All Python exercises · 50 practice problems · Data Science & Machine Learning quiz