<jupyter_start><jupyter_text>NumPy ExercisesNow that we've learned about NumPy let's test your knowledge. We'll start off with a few simple tasks and then you'll be asked some more complicated questions.IMPORTANT NOTE! Make sure you don't run the cells directly above the example output shown, otherwise you will end up writing over the example output!  1. Import NumPy as np<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>2. Create an array of 10 zeros<jupyter_code># CODE HERE
np.zeros(10)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>3. Create an array of 10 ones<jupyter_code>np.ones(10)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>4. Create an array of 10 fives<jupyter_code>np.ones(10)*5
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>5. Create an array of the integers from 10 to 50<jupyter_code>np.arange(10,51)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text><jupyter_code><jupyter_output><empty_output><jupyter_text>6. Create an array of all the even integers from 10 to 50*   List item*   List item<jupyter_code>np.arange(10,51,2)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>7. Create a 3x3 matrix with values ranging from 0 to 81.   List item2.   List item<jupyter_code>arr = np.arange(0,9)
arr.reshape(3,3)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>8. Create a 3x3 identity matrix<jupyter_code>np.eye(3)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>9. Use NumPy to generate a random number between 0 and 1&emsp;NOTE: Your result's value should be different from the one shown below.<jupyter_code>np.random.rand(1)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>10. Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution&emsp;&ensp;NOTE: Your result's values should be different from the ones shown below.<jupyter_code>np.random.normal(0,1,25)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>11. Create the following matrix:<jupyter_code>arr = np.arange(0.01,1.01,.01)
arr.reshape(10,10)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>12. Create an array of 20 linearly spaced points between 0 and 1:<jupyter_code>np.linspace(0,1,20)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>Numpy Indexing and SelectionNow you will be given a starting matrix (be sure to run the cell below!), and be asked to replicate the resulting matrix outputs:<jupyter_code># RUN THIS CELL - THIS IS OUR STARTING MATRIX
mat = np.arange(1,26).reshape(5,5)
mat<jupyter_output><empty_output><jupyter_text>13. Write code that reproduces the output shown below.&emsp;&ensp;Be careful not to run the cell immediately above the output, otherwise you won't be able to see the output any more.<jupyter_code># CODE HERE
mat[2:,1:]
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>14. Write code that reproduces the output shown below.<jupyter_code>mat[3,4]
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>15. Write code that reproduces the output shown below.<jupyter_code>mat[0:3,1].reshape(3,1)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>16. Write code that reproduces the output shown below.<jupyter_code>mat[4,0:5]

# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>17. Write code that reproduces the output shown below.<jupyter_code>mat[3:,0:5]
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>NumPy Operations  18. Get the sum of all the values in mat<jupyter_code>mat.sum()
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>19. Get the standard deviation of the values in mat<jupyter_code>mat.std()
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>20. Get the sum of all the columns in mat<jupyter_code>mat.sum(axis = 0)
# DON'T WRITE HERE<jupyter_output><empty_output><jupyter_text>Bonus QuestionWe worked a lot with random data with numpy, but is there a way we can insure that we always get the same random numbers? What does the seed value mean? Does it matter what the actual number is? [Click Here for a Hint](https://www.google.com/search?q=numpy+random+seed)<jupyter_code>the way to ensure that we get the same random numbers on the same machines or even on the different machines we should use the concept of SEED(). when we use seed value like np.random.seed(42) everyone using the same seed value will get the same set of random numbers even on different machines. the seed number should remains same otherwise we would not be getting the same values.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09151882302033752, 'fraction_numerical': 0.027260926006057985, 'mean_word_length': 6.743718592964824, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 93, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '145343', 'license': 'MIT', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1584, 'n_words': 495, 'path': 'Numpy_Assignment.ipynb', 'repo_name': 'ujjwalk39/awesome-public-datasets', 'size': '4622'}