<jupyter_start><jupyter_text>100 numpy exercisesThis is a collection of exercises that have been collected in the numpy mailing list, on stack overflowand in the numpy documentation. The goal of this collection is to offer a quick reference for both oldand new users but also to provide a set of exercises for those who teach.If you find an error or think you've a better way to solve some of them, feelfree to open an issue at . File automatically generated. See the documentation to update questions/answers/hints programmatically. Run the `initialize.py` module, then for each question you can query theanswer or an hint with `hint(n)` or `answer(n)` for `n` question number.  1. Import the numpy package under the name `np` (★☆☆)<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>2. Print the numpy version and the configuration (★☆☆)<jupyter_code>np<jupyter_output><empty_output><jupyter_text>3. Create a null vector of size 10 (★☆☆)<jupyter_code>x = np.zeros(10)
x<jupyter_output><empty_output><jupyter_text>4. How to find the memory size of any array (★☆☆)<jupyter_code>x.size<jupyter_output><empty_output><jupyter_text>5. How to get the documentation of the numpy add function from the command line? (★☆☆)<jupyter_code>#python -c "import numpy; numpy.info(numpy.add)"<jupyter_output><empty_output><jupyter_text>6. Create a null vector of size 10 but the fifth value which is 1 (★☆☆)<jupyter_code>x[5] = 1
x<jupyter_output><empty_output><jupyter_text>7. Create a vector with values ranging from 10 to 49 (★☆☆)<jupyter_code>a = np.array(range(10,50))<jupyter_output><empty_output><jupyter_text>8. Reverse a vector (first element becomes last) (★☆☆)<jupyter_code>np.flip(a)<jupyter_output><empty_output><jupyter_text>9. Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆)<jupyter_code>threexthree = np.arange(9)
threexthree.reshape(3,3)<jupyter_output><empty_output><jupyter_text>10. Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆)<jupyter_code>x = np.array([1,2,0,0,4,0])
np.nonzero(x)<jupyter_output><empty_output><jupyter_text>11. Create a 3x3 identity matrix (★☆☆)<jupyter_code>z = np.eye(3)
z<jupyter_output><empty_output><jupyter_text>12. Create a 3x3x3 array with random values (★☆☆)<jupyter_code>z = np.random.random((3,3,3))
z<jupyter_output><empty_output><jupyter_text>13. Create a 10x10 array with random values and find the minimum and maximum values (★☆☆)<jupyter_code>x = np.random.random((10,10,10))
x.min(), x.max()<jupyter_output><empty_output><jupyter_text>14. Create a random vector of size 30 and find the mean value (★☆☆)<jupyter_code>y = np.random.random(30)
y.mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1207801950487622, 'fraction_numerical': 0.030382595648912228, 'mean_word_length': 6.985029940119761, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '302725', 'license': 'MIT', 'n_tokens_mistral': 1009, 'n_tokens_neox': 978, 'n_words': 278, 'path': '100_Numpy_exercises.ipynb', 'repo_name': 'justin-m-sullivan/numpy-100', 'size': '2666'}