{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practice Problems\n", "### Lecture 13\n", "\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_13\n", "\n", "Turn this in with Canvas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Matplotlib.pyplot\n", "- Use **open(file).readlines()** to peek at the data in the file:\n", " \"Datasets/Tides/SDtides.csv\"\n", "- import the data into a pandas DataFrame\n", " - the data file contains information about High and Low Tides predicted for SIO (in 2017). For up to date charts, go to: [https://tidesandcurrents.noaa.gov/noaatideannual.html?id=9410170](https://tidesandcurrents.noaa.gov/noaatideannual.html?id=9410170)\n", "- plot a line chart of high tide (cm) for the first 60 days of the year \n", " - include a title, x-axis label, and y-axis label\n", "- add a line chart of low tide (cm) to the same plot\n", "- include a legend in your figure\n", "\n", "\n", "## 2. Matplotlib.pyplot.figure.add_subplot( )\n", "- Use **fig.add_subplot( )** to plot High tide (cm) for the first 60 days and Low tide (cm) for the first 60 days in two subplots that are side-by-side.\n", "- Add a title, y label, and x label to each figure\n", "\n", "\n", "## 3. Bar charts\n", "- use **plt.bar( )** to plot the height at low tide for the first 60 days of the year\n", "- include a title, x-axis label, y-axis label\n", "\n", "## 4. Exceptions\n", "- write a regular function that takes a single parameter and squares it\n", "- write a **for** loop that squares all the values in this list:\n", " values = [ 0., 11., 2, 22., 's', 33., 'c', 44., 55., 66., 'a', 77., 88., 99., 110., 121., 'w']\n", "\n", "- Use the error message to learn what type of error is thrown when the program encounters a string instead of an integer.\n", "- Include a **try-except** statement that catches this type of error and prints out the offending values" ] }, { "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 }