np.save requires two arguments: filename and array to save.
Step 2: Identify missing argument
The code calls np.save with only filename, missing the array argument.
Final Answer:
np.save is missing the array argument -> Option B
Quick Check:
np.save needs filename and array [OK]
Hint: np.save needs filename and array [OK]
Common Mistakes:
Forgetting to pass the array to np.save
Thinking np.load can't read .npy files
Believing .npy extension is wrong
5. You have a large NumPy array data that you want to save and share with a colleague. Which approach is best to ensure your colleague can load it exactly as you saved it, and why?
hard
A. Save with np.save and share the .npy file because it preserves array shape and data type
B. Convert array to string and save as .txt because text files are universal
C. Save with np.savez_compressed but rename file to .txt for easy sharing
D. Print array to console and ask colleague to copy-paste it
Solution
Step 1: Understand file formats for saving arrays
.npy files save arrays with shape and data type intact, ideal for sharing.
Step 2: Evaluate options for sharing
Text files lose shape and type info; renaming compressed files confuses loading; copy-paste is error-prone.
Final Answer:
Save with np.save and share the .npy file because it preserves array shape and data type -> Option A
Quick Check:
.npy files keep data exact [OK]
Hint: Use .npy files to keep array exact for sharing [OK]