• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 4 pages
Summary

Résumé Fiche Maths Terminale spé : Python, listes et tous les algorithmes du programme, codes testés (4 p.)

Document preview thumbnail
Preview 1 out of 4 pages

Fiche de révision Terminale spécialité maths sur l'algorithmique en Python : listes (extension, append, compréhension, indices, parcours) et un code court testé, avec sa sortie, pour chaque algorithme du programme : seuil, approximations de π, e, √2, φ, ln 2, dichotomie, Newton, sécante, Briggs, Euler, rectangles, Monte-Carlo, Brouncker, Pascal, permutations, Galton, surréservation, marche aléatoire, échantillons. 16 schémas. Mots-clés : terminale, bac, python, listes python, algorithmes maths, dichotomie, méthode deuler, spécialité maths. Fiche Le Cartouche pour réviser efficacement un contrôle, le bac blanc ou le bac.

Content preview

■ FICHE N°48 · MATHÉMATIQUES


PYTHON : LISTES ET ALGORITHMES
Listes, parcours, boucles, et un programme testé pour chaque algorithme du programme
NIVEAU Terminale, spécialité mathématiques

CONTENU 4 pages · 16 schémas · 20 programmes exécutés · sorties indiquées


1 LES LISTES : CRÉER, LIRE, MODIFIER
UNE LISTE // type list L[0] → 5 L[-1] → 34
indice 0 1 2 3 4 5
Suite ordonnée d'éléments, repérés par leur indice : le
premier est L[0], le dernier L[len(L)-1] (ou L[-1]). Une liste L = 5 8 13 21 34 55
se modifie sur place. Trois façons de la générer :
depuis −5 −4 −3 −2 −1
la fin
L = [5, 8, 13, 21] # en extension L.append(55)
C = [] # liste vide, puis
for k in range(6): # ajouts successifs len(L) → 5 : indices de 0 à 4
C.append(k**2) Indices de 0 à 4 (ou de −5 à −1 depuis la fin) ; append ajoute en fin
print(C) # → [0, 1, 4, 9, 16, 25] de liste (indice 5).
D = [k**2 for k in range(6)] # en compréhension
M = [k for k in range(20) if k % 3 == 0]
print(M) # → [0, 3, 6, 9, 12, 15, 18]
[k**2 for k in range(10) if k % 2 == 1]

expression source
Lien avec les ensembles : M décrit {k ∈ N ∣ k ⩽ variable condition (facultative)
19 et k multiple de 3}. Mais une liste est ordonnée et admet
les répétitions : [1, 1, 2] ≠ [1, 2]. 0 1 2 … 9 1 3 5 7 9 1 9 25 49 81
Liste des termes d'une suite (celle du §3) : range(10) garde k impair calcule k**2

U = [50] # U[k] contiendra u(k)
résultat : [1, 9, 25, 49, 81]
for k in range(14): Compréhension : on parcourt la source, on garde les éléments qui
U.append(0.8*U[-1] + 2) # calcul sur le dernier vérifient la condition, on calcule l'expression.
print(len(U), round(U[14], 3)) # → 15 11.759

Opérations usuelles : on repart à chaque fois de L = [5, 8, 13, 21].
ACTION INSTRUCTION RÉSULTAT ACTION INSTRUCTION RÉSULTAT
Longueur, lecture len(L) · L[0] · L[-1] 4 · 5 · 21 Supprimer (indice) del L[0] [8, 13, 21]

Modifier L[1] = 9 [5, 9, 13, 21] Supprimer (valeur) L.remove(13) [5, 8, 21]

Ajouter en fin L.append(34) [5, 8, 13, 21, 34] Appartenance 13 in L · 7 in L True · False
Insérer L.insert(0, 2) [2, 5, 8, 13, 21] Concaténer, répéter [1, 2] + [3] · [0] * 3 [1, 2, 3] · [0, 0, 0]
Supprimer (indice) L.pop(1) → renvoie 8 [5, 13, 21] Somme, max, min sum(L) · max(L) · min(L) 47 · 21 · 5


2 PARCOURIR UNE LISTE, SUIVRE LES VARIABLES
notes = [12, 15.5, 9, 14] DEUX FAÇONS DE PARCOURIR
s = 0
for x in notes: # par les éléments for x in L: itère sur les éléments (lecture).
s = s + x for i in range(len(L)): parcourt les indices :
print(s / len(notes)) # → 12.625
for i in range(len(notes)): # par les indices
indispensable pour modifier L[i].
if notes[i] < 10: range(n) : 0, 1, … , n − 1 ; range(a, b) : a, … , b −1;
notes[i] = 10 # modification sur place
print(notes) # → [12, 15.5, 10, 14] range(a, b, p) : pas p. La borne de fin est exclue.

Tableau d'évolution des variables (à gauche) : une
1RE BOUCLE DÉPART TOUR 1 TOUR 2 TOUR 3 TOUR 4
colonne par tour de boucle. À la fin,
x – 12 15.5 9 14 s / len(notes) = 50. = 12.625.
s 0 12 27.5 36.5 50.5


PIÈGES CLASSIQUES
Le premier indice est 0 : L[len(L)] provoque une erreur L2 = L ne copie pas : modifier L2 modifie L. Copier avec
IndexError. [x for x in L].
range(1, n) s'arrête à n − 1 : pour aller jusqu'à n, écrire L.append(x) modifie L et renvoie None : ne pas écrire L =
range(1, n+1). L.append(x).

= affecte, == compare (dans un if ou un while). Un return placé dans la boucle arrête la fonction au
premier tour : attention à l'indentation.


LE CARTOUCHE Fiche n°48 · Mathématiques

Document information

Study
Lycée
School year
1
Uploaded on
October 22, 2026
Number of pages
4
Written in
2026/2027
Type
Summary
$3.94

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
121
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions