0
0
NumPydata~5 mins

np.save() and np.load() for binary in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does np.save() do in NumPy?

np.save() saves a NumPy array to a binary file on your disk. This file stores the array data efficiently so you can load it later.

Click to reveal answer
beginner
How do you load a NumPy array saved with np.save()?

You use np.load() with the filename to read the binary file and get back the original NumPy array.

Click to reveal answer
intermediate
Why use binary files with np.save() instead of text files?

Binary files are faster to read/write and use less space. They keep the exact data format without converting to text, which can lose precision or be slower.

Click to reveal answer
beginner
What file extension does np.save() add by default?

It adds .npy to the filename automatically if you don't include it.

Click to reveal answer
intermediate
Can np.load() load files saved by np.save() from different Python sessions or machines?

Yes, as long as the file is not corrupted and the NumPy versions are compatible, np.load() can load the saved binary array across sessions or machines.

Click to reveal answer
What is the default file extension added by np.save()?
A.csv
B.txt
C.npy
D.bin
Which function do you use to read a binary file saved by np.save()?
Anp.load()
Bnp.read()
Cnp.open()
Dnp.import()
Why is saving arrays in binary format better than saving as text?
ABinary files convert data to strings
BBinary files are slower to read
CBinary files are human-readable
DBinary files save space and keep exact data
If you save an array with np.save('data'), what is the actual filename?
Adata.npy
Bdata
Cdata.txt
Ddata.bin
Can np.load() open files saved by np.save() on another computer?
AOnly if saved as CSV
BYes, if the file is intact and NumPy versions are compatible
COnly if the file is converted to text first
DNo, only on the same computer
Explain how to save and load a NumPy array using np.save() and np.load().
Think about saving data to disk and reading it back exactly.
You got /4 concepts.
    Why is it better to save NumPy arrays in binary format rather than as text files?
    Consider speed, size, and data accuracy.
    You got /4 concepts.