Python au lycée (3) : Les boucles Entraînement

Vrai/Faux : Sommes et compteurs avec for (niveau 2)

Durée estimée
5 minutes
Difficulté
Votre progression

Créez un compte gratuit pour suivre votre avancement et reprendre où vous avez laissé.

Créer un compte

Objectifs travaillés

Pour chaque affirmation suivante sur les accumulations et compteurs avec for en Python, indiquez si elle est Vraie ou Fausse.

Déroulement pas à pas (Correction et Indices)

Question 1 :

On exécute le programme Python ci-dessous :

S = 0
for i in range(1, 101) :
    S = S + i
print(S)

Affirmation : Ce programme affiche la somme $1 + 2 + \ldots + 100 = 5050$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 2 :

On exécute le programme Python ci-dessous :

S = 0
for i in range(1, 5) :
    S = S + i*i
print(S)

Affirmation : Ce programme affiche $30$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 3 :

On exécute le programme Python ci-dessous :

P = 0
for i in range(1, 6) :
    P = P * i
print(P)

Affirmation : Ce programme affiche $120$ (soit $1 \times 2 \times 3 \times 4 \times 5$).

  • (Incorrect) Vrai
  • (Correct) Faux
Question 4 :

On exécute le programme Python ci-dessous :

c = 0
for i in range(1, 11) :
    if i % 2 == 0 :
        c = c + 1
print(c)

Affirmation : Ce programme affiche $5$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 5 :

On exécute le programme Python ci-dessous :

S = 0
for i in range(10) :
    S = S + i
print(S)

Affirmation : Ce programme affiche $55$ (soit $1 + 2 + \ldots + 10$).

  • (Incorrect) Vrai
  • (Correct) Faux
Question 6 :

On exécute le programme Python ci-dessous :

m = 0
for x in [5, 8, 3, 12, 7] :
    if x > m :
        m = x
print(m)

Affirmation : Ce programme affiche $12$.

  • (Correct) Vrai
  • (Incorrect) Faux