Project 20: Plan Usage Sparse Matrix
Scientific Computing
Current Task
Objective
Review day: build a sparse matrix — days 7-8 — and inspect it.
Task: build a sparse plan usage matrix and print its non-zero count and dense form.
index.py
from scipy.sparse import csr_matrix
import numpy as np
plan_usage = csr_matrix(np.array([[0, 3, 0], [1, 0, 0], [0, 0, 5]]))
print(plan_usage.nnz)
print(plan_usage.toarray())
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview