Q:

Write a NumPy program to save a given array to a binary file

0

Write a NumPy program to save a given array to a binary file

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
import os
a = np.arange(20)
np.save('temp_arra.npy', a)
print("Check if 'temp_arra.npy' exists or not?")
if os.path.exists('temp_arra.npy'):
    x2 = np.load('temp_arra.npy')
    print(np.array_equal(a, x2))

Sample Output:

Check if 'temp_arra.npy' exists or not?
True

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now