Materials to brush up your Python skills
This session is based on a Python file. When you open this file with Visual Studio Code, you will notice pseudo-cells prefixed as follows:
Clicking on Run Cell
(or pressing Maj+Enter
) runs an IPython kernel appearing (usually) on the right side of your screen.
This approach is comfortable to preliminary projects:
The file is located in the python/
folder:
numpy_demo.py
This is a selection of exercises from https://github.com/rougier/numpy-100
Reverse a vector. You may use vector x
defined as follows:
x = np.arange(50)
Find the min and max values in a 10x10 array. Find their indices.
x = np.random.random((10, 10))
Create a 2d array with 1 on the border and 0 inside.
Create a 5x5 matrix with values 1,2,3,4 just below the diagonal
Create a 8x8 matrix and fill it with a checkerboard pattern
Normalize a 5x5 random matrix
x = np.random.random((5, 5))