Lecture 3 : Scientific computing with Python (Correction)

November, 2021 - François HU

Master of Science in Artificial Intelligence Systems - EPITA

This lecture is available here: https://curiousml.github.io/

Exercice 1

generate arr1:

[[ 0  4  8 12 16]
 [ 1  5  9 13 17]
 [ 2  6 10 14 18]
 [ 3  7 11 15 19]]

generate arr2

[[ 0  1  4  9 16]
 [ 1  4  9 16 25]
 [ 4  9 16 25 36]
 [ 9 16 25 36 49]]

generate arr3

[[0 1 0 1 0 1]
 [1 0 1 0 1 0]
 [0 1 0 1 0 1]
 [1 0 1 0 1 0]
 [0 1 0 1 0 1]
 [1 0 1 0 1 0]]

Exercice 3

extract from arr1

[[ 6 18 10]
 [ 7 19 11]
 [ 5 17  9]]

Exercice 4.

Replace all the items with value 0 of arr3 by -1

Exercice 4 bis

Create a random vector of size 20 (all values between $[0, 1)$) and replace: