In [31]:
import numpy as np
import matplotlib.pyplot as plt

Problem: file io, dictionaries

  • Download file names.txt.
  • Download file ages.txt.
  • Use numpy to load the files into separate variables.
    • To do this you will need to include an extra function argument as follows: dtype=str.
  • Create a dictionary that maps names to ages based on this data.
  • Loop through each item and print the key and value to the screen.
In [ ]:

Problem: classes

  • Create a class to work with complex numbers.
  • The class should have an appropriate initialization function.
  • Create a function to add two complex numbers and return the result.
  • Create a function that returns the complex conjugate.
In [ ]:

Problem: arrays, plot

Solve the following rate equations for velocity $v$ and position $x$ using the Explicit Euler (EE) method: $$\frac{dv}{dt} = g-cv^2,$$ $$\frac{dx}{dt} = v.$$

  • Use initial conditions of $v(0) = 0$, $x(0) = 0$.
  • Use a step size of $\Delta t=0.1$.
  • Solve to $t=5$ seconds.
  • On a single plot, show the $v(t)$ and $x(t)$ curves.
    • Include a legend, and axis labels with units.
In [ ]: