<jupyter_start><jupyter_text>NumPy exercises<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>Q1We can use `np.random.random_sample()` to create an array with random values.  By default, these will be in the range `[0.0, 1.0)`.  You canmultiple the output and add a scalar to it to get it to be in a different range.Create a 10 x 10 array initialized with random numbers that lie between 0 and 10.Then compute the average of the array (there is a numpy function for this, `np.mean()`).  Q2Create the array: ```[[1,  6, 11], [2,  7, 12], [3,  8, 13], [4,  9, 14], [5, 10, 15]]```with out explicitly typing it in.Now create a new array containing only its 2nd and 4th rows.  Q3Create a 2d array with `1` on the border and `0` on the inside, e.g., like:```1 1 1 1 11 0 0 0 11 0 0 0 11 1 1 1 1```Do this using array slice notation to let it work for an arbitrary-sized array  Q4  * Create an array with angles in degrees 0, 15, 30, ... 90 (i.e., every 15 degrees up to 90).  * Now create 3 new arrays with the sine, cosine, and tangent of the elements of the first array    * Finally, calculate the inverse sine, inverse cosine, and inverse tangent the arrays above and compare to the original angles  Q5Given the array:```x = np.array([1, -1, 2, 5, 8, 4, 10, 12, 3])```calculate the difference of each element with its neighbor.  Q6Now we want to construct a derivative, $$\frac{d f}{dx}$$We want to do this without loops&mdash;we'll use views into arrays offset from one another.  Recall from calculus that a derivative is approximately:$$\frac{df}{dx} = \frac{f(x+h) - f(x)}{h}$$Here, we'll take $h$ to be a single adjacent element<jupyter_code>x = np.linspace(0, 2*np.pi, 25)
f = np.sin(x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10945558739255014, 'fraction_numerical': 0.05157593123209169, 'mean_word_length': 4.243243243243243, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '631915', 'license': 'Unlicense', 'n_tokens_mistral': 633, 'n_tokens_neox': 547, 'n_words': 275, 'path': 'day2/07. numpy - exercises.ipynb', 'repo_name': 'ubutnux/bosscha-python-workshop-2022', 'size': '1745'}