<jupyter_start><jupyter_text>Institute of Applied AI Engineers  1. Generate a 1D NumPy array containing numbers from -2 to 2 in increments of 0.2. Use optional start and step arguments of np.arange() function.<jupyter_code>import numpy as np
np.arange(-2,2,0.2)<jupyter_output><empty_output><jupyter_text>2. Generate another 1D NumPy array containing 11 equally spaced values between 0.5 and 1.5. Extract every second element of the array<jupyter_code>np.linspace(0.5,1.5,11)<jupyter_output><empty_output><jupyter_text>3. Create a 4x4 array with arbitrary values.Extract every element from the second row.<jupyter_code>b= np.random.randn(4,4)<jupyter_output><empty_output><jupyter_text>4. Extract every element from the third column<jupyter_code>b[:,2]<jupyter_output><empty_output><jupyter_text>5. Assign a value of 0.21 to upper left 2x2 subarray.<jupyter_code>b[0:2,0:2] =0.21
print(b)<jupyter_output>[[ 0.21        0.21       -0.49041993 -0.14763616]
 [ 0.21        0.21       -1.48488588 -0.79672559]
 [-0.28984804  1.24002033 -2.901839    0.06202299]
 [ 0.39630373 -0.9421009  -0.01269074  0.83664255]]<jupyter_text>6. Read an 2D array from the file exercise1_4.dat. You can usethe function np.loadtxt():data = np.loadtxt(‘exercise1_4.dat’) Split the array into four subblocks (upper left, upper right, lower left, lower right) using np.split(). Construct then the full array again with np.concatenate(). You can visualize the various arrays with matplotlib’s imshow(), i.e. import pylab pylab.imshow(data)<jupyter_code>a =np.array((2,3,4,5,6,7))
print(a)
np.savetxt('test.dat', a, delimiter=',')
b=np.loadtxt('test.dat')
print(b)
c =np.split(b,3)
d=c[0]
e=c[0]
f=c[2]
print(d,e,f)
data =np.concatenate((d,e,f))<jupyter_output>[ 2.  3.] [ 2.  3.] [ 6.  7.]
{'fraction_non_alphanumeric': 0.1362088535754824, 'fraction_numerical': 0.10385925085130533, 'mean_word_length': 4.956081081081081, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '348334', 'license': 'MIT', 'n_tokens_mistral': 786, 'n_tokens_neox': 693, 'n_words': 176, 'path': 'Numpy 2.ipynb', 'repo_name': 'MArsalaan/Digital-Image-Processing', 'size': '1762'}