{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practice Problems\n", "### Lecture 7\n", "Answer each number in a separate cell\n", "\n", "Rename this notebook with your last name and the lecture \n", " \n", " ex. Cych_B_07\n", " \n", "Turn-in this notebook on Canvas. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Generate arrays\n", " - Use **NumPy** to generate an array of integers ranging from 0 up to 360 by intervals of 10.\n", " - Use **NumPy** to generate an array from 0 to 2$\\pi$ with 36 values (use the **NumPy** attribute **pi**)\n", " - print them both out. \n", " - Use **NumPy** to generate an array with 20 equally spaced floating point numbers between 0 and 2$\\pi$ and print it out. \n", "2. Array slicing\n", " - Load the data file _Datasets/RecentEarthquakes/earthquakeLocations.txt_ into a **NumPy** array. Remember that the folder _Datasets_ is in the directory above the one that this notebook is in! The data file contains the latitude and longitude of 10 different earthquakes.\n", " - Print out the shape of the array you just imported \n", " - Convert the shape of the array to 2x10. Use both the **.reshape()** and **.transpose()** methods. \n", " - Print the shape of the two new arrays\n", " - Take a slice of only the latitudes and assign it in a new variable **lats**\n", " - Take a slice of only the longitudes and assign it in a new variable **lons**. \n", " - Print the type of the variable **lats** and **lons**\n", " - Convert the new arrays, **lats** and **lons**, into separate lists and assign them to new variable names\n", " - Print the type of these two new variables\n", " - Save the numpy array **lats** into a text file labeled 'lats.txt'\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Resources:\n", "\n", "http://ds.iris.edu/ieb/index.html?format=text&nodata=404&starttime=1970-01-01&endtime=2025-01-01&minmag=0&maxmag=10&mindepth=0&maxdepth=900&orderby=time-desc&limit=1000&maxlat=89.18&minlat=-89.18&maxlon=180.00&minlon=-180.00&zm=1&mt=ter) " ] }, { "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.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }