{ "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", "Given the following NumPy array, return the first element and the last element." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "arr = np.array([8,2,4,9,7,3,8,1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Return the first element here" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Returns the last element here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 3\n", "Given the following NumPy array, return the entire array except for the last element." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "new_arr = np.array([1,6,4,8,7,5,2,1,4,5,6,1,4,5,6,2,1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Place your solution here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 4\n", "Change the second element of `this_arr` to `4`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "this_arr = np.array([2,4,89,7,5,4,2,6,4,5,78,1,6,9,7,456,12,45])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Place your solution here\n", "this_arr[1] = 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 5\n", "Given the array `original_array`, create a reference to that array called `reference_array`. Change the second element of `reference_array` to `16` and then print `original_array` to verify that it modified the original data structure." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "original_array = np.array([12,45,86,79,45,26,13,46,28])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Solution goes here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 6\n", "Given the array `first_array`, create a copy of the array called `copy_array`. Change the third element of `copy_array` to `42` and then print `first_array` to verify that its elements remain unchanged." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "first_array = np.array([16,45,75,16,43,45,78,19,23,46,79,58])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Solution goes here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 7\n", "Given the two-dimensional array `matrix`, print the value `35`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "matrix = np.array([[15, 120, 115],[230, 35, 130],[335, 420, 425]])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Solution goes here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 8\n", "Given the array `integer_array`, print a NumPy array of Boolean values that indicate whether the corresponding values in `integer_array` are greater than 4." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "integer_array = np.array([2,6,4,9,8,5,3,1,2,5,4,8,7,5,6])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Solution goes here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem \n", "Given the same array `integer_array`, print a new NumPy array that only includes the values from `integer_array` that are less then `6`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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 }