Practice Problems

Lecture 6

Answer each number in a separate cell

Rename this notebook with your last name and the lecture ex. CychB_06

Turn-in this notebook on TritonEd by the end of class.

  1. Numpy attributes

    • print out the value of e using the np.e attribute.
  2. Numpy

    • Create a list of numbers ranging from 1931 to 2016
    • Read in 'Datasets/rainFall/Avg_Rain.txt' in the Lecture_06 directory into an ndarray using NumPy. These data came from: the Knipling-Bushland US Livestock Insects Research Laboratory, USDA-ARS in Kerrville, Texas. The file contains total annual rainfall.
    • Plot the annual average rainfall against your list of numbers.
    • Label the $x$ and $y$ axes.
    • What do you suppose the units of rainfall are?
  3. Matplotlib.pyplot
    • import matplotlib.pyplot as plt
    • create a list of angles called thetas_in_radians
    • Use your array thetas_in_radians to generate an array of tangents (using the appropriate NumPy function (listed in the Lecture).
    • Plot this array with thetas_in_radians on the X axis and your array of tangents on the y axis. Draw the tangent with a red line.
    • Try different line styles, different line widths, and colors. (look at the matplotlib.pyplot API link, or use the Python help( ) function.
    • Put on axis labels and a legend. Play with the legend location.
    • set the y limits to -1 and 1
In [ ]: