<jupyter_start><jupyter_text>NumPy Lab Exercises Solve the following questions  Import NumPy package as np<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>Create an empty array of 20 0's and replace the 4th object with the number 5<jupyter_code>nparr = np.zeros(20)
nparr [3] = 5
print(nparr)<jupyter_output>[0. 0. 0. 5. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]<jupyter_text>Create an array of 20 1's and store it as a variable named array_master. Copy the same array into another variable named array_copy<jupyter_code>array_master = np.ones(20) 
array_copy = array_master.copy()
array_copy<jupyter_output><empty_output><jupyter_text>Create an array containing 30 1's and broadcast all the one's to the value 100<jupyter_code>nparr100 = np.ones(30)
nparr100[:] = 100
nparr100<jupyter_output><empty_output><jupyter_text>Create an array of integers starting from 21 until 31 and name it as array1 Create an array of integers starting from 11 until 21 and name it array2 Calculate the difference between array1 and array2<jupyter_code>np.arange(21,32)- np.arange(11,22)<jupyter_output><empty_output><jupyter_text>Create an array of all even integers from 2 to 10 and name it a1 Create an array of all even integers from 22 to 30 and name it a2  a) Use the 2 arrays as rows and create a matrix [ Hint - Use stack function from numpy ]<jupyter_code>a1 = np.arange(2,11,2)
a2 = np.arange(22,31,2)

np.stack((a1,a2),axis=0)<jupyter_output><empty_output><jupyter_text>b) Use the 2 arrays as columns and create a matrix [ Hint - Use column_stack function from numpy ]<jupyter_code>np.column_stack((a1,a2))<jupyter_output><empty_output><jupyter_text>Create a 5x6 matrix with values ranging from 0 to 29 and retrieve the value intersecting at 2nd row and 3rd column<jupyter_code>mat = np.matrix(np.arange(0,30).reshape(5,6))
print (mat)
print (mat[1,2])<jupyter_output>[[ 0  1  2  3  4  5]
 [ 6  7  8  9 10 11]
 [12 13 14 15 16 17]
 [18 19 20 21 22 23]
 [24 25 26 27 28 29]]
8<jupyter_text>Create an identity matrix of shape 10x10 and replace the 0's with the value 21<jupyter_code>mat1 = np.eye(10)
mat2 = (mat1==0)
mat1[mat2] = 21 
mat1<jupyter_output><empty_output><jupyter_text>Use NumPy to generate a random set of 10 numbers between 0 and 1 Display a boolean array output where all values > 0.2 are True, rest are marked as False<jupyter_code>np.random.rand(10) > 0.2<jupyter_output><empty_output><jupyter_text>Use NumPy to generate an array matrix of 5x2 random numbers sampled from a standard normal distribution<jupyter_code>np.random.randn(10).reshape(5,2)<jupyter_output><empty_output><jupyter_text>Create an array of 30 linearly spaced points between 0 and 100:<jupyter_code>np.linspace(0,100,30)<jupyter_output><empty_output><jupyter_text>Numpy Indexing and SelectionsUsing the below given Matrix, generate the output for the below questions<jupyter_code>simple_matrix = np.arange(1,101).reshape(10,10)
simple_matrix<jupyter_output><empty_output><jupyter_text>a) Retrieve the last 2 rows and first 3 column values of the above matrix using index & selection technique<jupyter_code>simple_matrix[7:,:3]<jupyter_output><empty_output><jupyter_text>b) Retrieve the value 55 from the above matrix using index & selection technique<jupyter_code>simple_matrix[5,4]<jupyter_output><empty_output><jupyter_text>c) Retrieve the values from the 3rd column in the above matrix<jupyter_code>simple_matrix[:,2]<jupyter_output><empty_output><jupyter_text>d) Retrieve the values from the 4th row in the above matrix<jupyter_code>simple_matrix[3,:]<jupyter_output><empty_output><jupyter_text>e) Retrieve values from the 2nd & 4th rows in the above matrix<jupyter_code>simple_matrix[(1,3),:]<jupyter_output><empty_output><jupyter_text>Calculate the following values for the given matrix  a) Calculate sum of all the values in the matrix<jupyter_code>simple_matrix.sum()<jupyter_output><empty_output><jupyter_text>b) Calculate standard deviation of all the values in the matrix<jupyter_code>simple_matrix.std()<jupyter_output><empty_output><jupyter_text>c) Calculate the variance of all values in the matrix<jupyter_code>simple_matrix.var()<jupyter_output><empty_output><jupyter_text>d) Calculate the mean of all values in the matrix<jupyter_code>simple_matrix.mean()<jupyter_output><empty_output><jupyter_text>e) Retrieve the largest number from the matrix<jupyter_code>simple_matrix.max()<jupyter_output><empty_output><jupyter_text>f) Retrieve the smallest number from the matrix<jupyter_code>simple_matrix.min()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09140727750986409, 'fraction_numerical': 0.051731696624287594, 'mean_word_length': 7.019332161687171, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 97, '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': '24', 'dir': 'jupyter-structured-clean-dedup', 'id': '172986', 'license': 'Apache-2.0', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1594, 'n_words': 474, 'path': 'Numpy_Lab_Exercise_Question.ipynb', 'repo_name': 'ABPande/MyPythonRepo', 'size': '4562'}