Python Reading
Key Ideas
- Creating np arrays
- Slicing and reshaping arrays
- Operations on arrays such as broadcasting
In-Class Activity
- Download broadcast.py and study it until
it is fully understood. The program illustrates
the concept of broadcasting.
Active Learning
Work through tutorial2.py and then
do the following:
- Create a vector z with values ranging from 10 to 49
- Reverse Z
- Create a 3x3 matrix m with values ranging from 0 to 8
- Create a 3x3x3 array r with random values
- Create a 3x3 identity matrix
- Can you figure out what the following code produces without
running it first?
z = np.zeros((5,5))
z += np.arange(5)
print(z)