Practice Problems

Lecture 13

Answer each number in a separate cell

Rename this notebook with your last name and the lecture

ex. Cych_13

Turn-in this notebook on triton-ed by the end of class

1. Matplotlib.pyplot

  • Use head to peek at the data in the file: "Datasets/Tides/SDtides.csv"
  • import the data into a pandas DataFrame
  • plot a line chart of high tide (cm) for the first 60 days of the year
    • include a title, x-axis label, and y-axis label
  • add a line chart of low tide (cm) to the same plot
  • include a legend in your figure

2. Matplotlib.pyplot.figure.add_subplot( )

  • Use 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.
  • Add a title, y label, and x label to each figure

3. Bar charts

  • use .bar( ) to plot the height at low tide for the first 60 days of the year
  • include a title, x-axis label, y-axis label

4. Exceptions

  • write a regular function that takes a single parameter and squares it
  • write a for loop that squares all the values in this list:

      values = [ 0., 11., 2, 22., 's',  33., 'c',  44.,   55.,   66., 'a',  77.,   88., 99.,  110.,  121., 'w']
  • Use the error message to learn what type of error is thrown when the program encounters a string instead of an integer.

  • Include a try-except statement that catches this type of error and prints out the offending values
In [ ]: