Complete the code to create a sparse matrix from a dense matrix using SciPy.
from scipy.sparse import [1] dense_matrix = [[0, 0, 3], [4, 0, 0], [0, 0, 0]] sparse_matrix = [1](dense_matrix)
The csr_matrix function from SciPy creates a sparse matrix from a dense matrix efficiently.
Complete the code to get the number of non-zero elements in a sparse matrix.
from scipy.sparse import csr_matrix sparse_matrix = csr_matrix([[0, 0, 3], [4, 0, 0], [0, 0, 0]]) non_zero_count = sparse_matrix.[1]
The nnz attribute gives the number of non-zero elements in a sparse matrix.
Fix the error in the code to convert a sparse matrix back to a dense array.
from scipy.sparse import csr_matrix sparse_matrix = csr_matrix([[0, 0, 3], [4, 0, 0], [0, 0, 0]]) dense_array = sparse_matrix.[1]()
The toarray() method converts a sparse matrix to a dense NumPy array.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
{word: [1] for word in words if [2]The dictionary comprehension maps each word to its length using len(word) and filters words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if count is greater than 0.
{ [1]: [2] for [3], [2] in data.items() if [2] > 0 }The comprehension maps uppercase keys k.upper() to their values v for each key k and value v in data.items(), filtering values greater than 0.