Solutions#

Solution to Exercise 2.14

# 1
for i in range(5, 17, 2):
    print(i)

# 2
for i in range(6):
    print(10**i)

# 3
for i in range(9):
    print(i % 3)

Solution to Exercise 2.15

import numpy as np
import matplotlib.pyplot as plt

temp_max = np.array([11, 11, 15, 14, 13, 9, 9, 9, 8, 7])
temp_min = np.array([8, 6, 11, 8, 7, 4, 4, 4, 3, 3])

plt.plot(temp_max, label="Max")
plt.plot(temp_min, label = "Min")
plt.xlabel("Day")
plt.ylabel("Temperature (degrees C)")
plt.legend()
plt.title("Daily Temperature in London")