python • 3 techniques très classiques pour créer des listes & comment rajouter, enlever des éléments

preview_player
Показать описание
3 techniques pour créer des listes en python:
- li=[...,...,...] à la main
- avec range et list
- avec l'opérateur *: [...]*
- comment rajouter des éléments à la fin d'une liste +[....] et la méthode append()
- comment rajouter un élément à une certaine position avec la méthode insert()
- comment enlever des éléments à une certaine position avec del li[...]
cours python lycée SNT
Рекомендации по теме
Комментарии
Автор

t'es vraiment meilleur

Tes vidéos me motivent

harounaba
Автор

Svp prof, comment générer les combinaisons sans ordres ni répétitions des loto ? Où on peut supprimer par exemple les chiffres impaires, paires, à 5 chiffres d'intervalles ou encore en supprimant les chiffres de son choix dans la combinaison à générer par exemple 4 parmi 52, je décide d'enlever (2, 5, 6, 8, 7, 24, 52, ...)

Merci d'avance

danieldiawakunzabanioffici
Автор

réponse exersice
li=[10, 12, 15, 13, 9, 8, 7, 6, 14, 19]
li2=[]
for i in li:
if i>10:
li2.append(i)
print (li2)

boumediennechetti
Автор

Salut pouvez vous m'aider à résoudre cet exercice svp

There is a mechanism that consists of nails and 10 chambers designed like the figure below. If you drop a coin from the top, it will fall into one of the chambers below by hitting one nail at each level. When a coin hits to a nail, it will fall through either left or right of it. User can input the number of coins that he/she wants to drop in this mechanism. The ouput of your program should;
Display the number of coins that fell into each chamber
Display the number of coins in each chamber using a histogram.
Enter the number of coins to drop..:50
Number of coins in chamber 1 is...: 0
Number of coins in chamber 2 is...: 2
Number of coins in chamber 3 is...: 2
Number of coins in chamber 4 is...: 8
Number of coins in chamber 5 is...: 13
Number of coins in chamber 6 is...: 10
Number of coins in chamber 7 is...: 9
Number of coins in chamber 8 is...: 5
Number of coins in chamber 9 is...: 1
Number of coins in chamber 10 is...: 0

mamadydiakite