Python au lycée (2) : Les instructions conditionnelles Entraînement

Vrai/Faux : Conditions composées et pièges (niveau 3)

Durée estimée
10 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 conditions composées et les pièges classiques en Python, indiquez si elle est Vraie ou Fausse.

Déroulement pas à pas (Correction et Indices)

Question 1 :

Affirmation : La condition not (x >= 5) est équivalente à x > 5.

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

On exécute le programme Python ci-dessous :

x = 3
y = 7
if x > 0 and y < 5 :
    print("X")
else :
    print("Y")

Affirmation : Ce programme affiche X.

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

On exécute le programme Python ci-dessous :

n = 5
if n < 0 :
    print("A")
elif n < 10 :
    print("B")
elif n < 100 :
    print("C")
else :
    print("D")

Affirmation : Ce programme affiche B puis C.

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

On exécute le programme Python ci-dessous :

a = 2
b = 5
if a == 1 or b == 5 :
    print("oui")
else :
    print("non")

Affirmation : Ce programme affiche oui.

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

On considère la fonction mathématique définie par :

$f(x) = -x + 1$ si $x \leqslant 0$, et $f(x) = 3x + 1$ si $x > 0$

On exécute le programme Python ci-dessous :

x = -2
if x <= 0 :
    y = -x + 1
else :
    y = 3*x + 1
print(y)

Affirmation : Ce programme affiche $3$.

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

On exécute le programme Python ci-dessous :

x = 7
est_positif = (x > 0)
print(est_positif)

Affirmation : Ce programme affiche True.

  • (Correct) Vrai
  • (Incorrect) Faux