Due January 18 at 8 PM
A quick introduction to git and python.
Please run through this tutorial on how git functions. Further reading on git exists here.
For an introduction to python programming, please follow the tutorials here and here.
We will cover certain aspects of python programming and specific packages throughout the course. However, at the end of these tutorials, you should be comfortable with the exercises below.
In [3]:
%matplotlib inline
import numpy as np
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt
In [12]:
def fib():
arr = np.zeros(100, dtype=np.float64)
arr[1] = 1
for ii in range(2, 100):
arr[ii] = arr[ii-1] + arr[ii-2]
return arr
seq = fib()
assert(seq[99] == seq[98] + seq[97])
assert(seq[2] == 1)
In [5]:
boston = load_boston()
y = boston.target
x = boston.data[:, 0]
ylabel = "Home Prices"
xlabel = "Crime"
plt.scatter(x, y);
plt.xlabel(xlabel);
plt.ylabel(ylabel);
In [20]:
def func(A, B):
return A + (2 * B)
assert(func(0, 20) == 40)
assert(func(1, 10) == 21)
assert(func(2, 5) == 12)
assert(func(3, 2) == 7)
assert(func(4, 1) == 6)
Answers.
Answers.