Lecture 6 bis : Additional exercices

December, 2021 - François HU

Master of Science - EPITA

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

image.png

Exercices

These exercices are considered "normal-hard" exercices.

Exercice 1: lists

Create a function insert, that produces the following results:

>>> l = [0, 9, 3, 10]
>>> print(insert(l, -1, 1))
[0, -1, 9, 3, 10]
>>> print(insert(l, -1, 2))
[0, 9, -1, 3, 10]
>>> print(insert(l, "epita", 4))
[0, 9, 3, 10, 'epita']
>>> print(insert(l, "epita", 10))
[0, 9, 3, 10, 'epita']
>>> print(l)
[0, 9, 3, 10]

Exercice 2: dictionaries

we have the following list of dictionaries

Exercice 3: strings

we have the following list of strings

Write a script that create a variable named text which concatenante the items of list_of_strings with exactly one space between words.

Exercice 4: arrays

[[  0  25 100 225 400]
 [  1  36 121 256 441]
 [  4  49 144 289 484]
 [  9  64 169 324 529]
 [ 16  81 196 361 576]]
[  0,  36, 144, 324, 576]
[[225 100  25]
 [289 144  49]
 [256 121  36]]

and name it subarr1.

Exercice 5: arrays

[[10  9  8  7  6]
 [ 9  8  7  6  5]
 [ 8  7  6  5  4]
 [ 7  6  5  4  3]
 [ 6  5  4  3  2]]

Exercice 6: plotting

image-2.png

Exercice 7: data manipulation

image.png

image-2.png

image.png