{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 1\n", "Import the NumPy library under the alias `np`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 2\n", "Create a NumPy array called `my_array` that contains the following elements: `1`, `3`, and `5`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 3\n", "Create a two-dimensional NumPy array with 9 elements. The array should be called `my_matrix` and should have 3 columns and three rows. The matrix can contain whatever values you'd like. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 4\n", "Use NumPy's `arange` method to generate the following output:\n", "\n", "`array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", " 17, 18, 19, 20])`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 5\n", "Use NumPy's `arange` method to generate the following output:\n", "\n", "`array([ 1, 4, 7, 10, 13])`\n", "\n", "Hint: You will need to use `arange`'s third argument." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 6\n", "Generate a NumPy array that contains 20 zeros." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 7\n", "Generate a NumPy array that contains 50 ones." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 8\n", "Using NumPy, divide the space between 0 and 100 into 1000 even intervals." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 9\n", "Create a 10x10 identity matrix using NumPy." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 10\n", "Returns a random sample of numbers with 10 values where each value is between 0 and 1." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 11\n", "Returns a random sample of numbers with 10 values where each value is between 0 and 10.\n", "\n", "Hint: Use the `random.rand` method combined with a multiplication operation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 12\n", "Generate a random sample of 15 numbers from a normal distribution." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 13\n", "Generate a random sample of 7 integers that range between 5 and 10." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 14\n", "Reshape the following one-dimensional NumPy array into a two-dimensional Numpy array with 3 rows and 3 columns." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "arr = np.array([0,1,2,3,4,5,6,7,8])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 15\n", "Print the minimum and maximum values of the following NumPy array." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "arr = np.array([0,1,2,3,4,5,6,7,8])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Print the minimum value here." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Print the maximum value here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 16\n", "For the following NumPy array, print the index of the minimum and maximum values." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_array = np.array([6, 7, 0, 2])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Print the minimum value's index here." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Print the maximum value's index here." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }