Python au lycée (5) : Les listes Entraînement

Vrai/Faux : Listes en Python

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

Objectif travaillé

Pour chaque affirmation suivante, indiquez si elle est Vraie ou Fausse.

Déroulement pas à pas (Correction et Indices)

Question 1 :

On exécute le programme Python ci-dessous :

l = [7, 9, 11, 13]
print(l[1])

Affirmation : Ce programme affiche $7$ comme résultat.

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

On exécute le programme Python ci-dessous :

a = [1, 2, 3]
b = [4, 5, 6]
print(a + b)

Affirmation : Ce programme affiche [5, 7, 9].

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

On définit la fonction Python ci-dessous :

def carres(n):
    return [i**2 for i in range(n)]

Affirmation : L'instruction carres(3) retourne la liste [0, 1, 4, 9].

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

On exécute le programme Python ci-dessous :

maListe = ["a", "b", "c", "d"]
print(len(maListe))

Affirmation : Ce programme affiche $4$ comme résultat.

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

On considère la fonction Python ci-dessous :

def f(liste):
    max = 0
    for a in liste:
        if a > max:
            max = a
    return max

Affirmation : L'instruction print(f([5, 8, 10, 3])) affiche le nombre $10$.

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

On considère le programme Python suivant :

liste = []
for i in range(4):
    liste.append(i)
print(liste)

Affirmation : Ce programme affiche la liste [0, 1, 2, 3].

  • (Correct) Vrai
  • (Incorrect) Faux