Vrai/Faux : Structures if, else, elif (niveau 2)
Créez un compte gratuit pour suivre votre avancement et reprendre où vous avez laissé.
Créer un compteObjectifs travaillés
Pour chaque affirmation suivante sur les structures if, else et elif 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 :
x = 4
if x > 0 :
print("positif")
else :
print("négatif ou nul")
Affirmation : Ce programme affiche positif.
x = 4
if x > 0 :
print("positif")
else :
print("négatif ou nul")- (Correct) Vrai
- (Incorrect) Faux
Question 2 : Affirmation : En Python, le mot-clé elif est une abréviation de else if.
- (Correct) Vrai
- (Incorrect) Faux
Question 3 : On exécute le programme Python ci-dessous :
n = 5
if n > 0 :
print("A")
if n > 3 :
print("B")
else :
print("C")
Affirmation : Ce programme affiche A puis B.
n = 5
if n > 0 :
print("A")
if n > 3 :
print("B")
else :
print("C")- (Correct) Vrai
- (Incorrect) Faux
Question 4 : On exécute le programme Python ci-dessous :
n = 5
if n > 0 :
print("A")
elif n > 3 :
print("B")
else :
print("C")
Affirmation : Ce programme affiche A puis B.
n = 5
if n > 0 :
print("A")
elif n > 3 :
print("B")
else :
print("C")- (Incorrect) Vrai
- (Correct) Faux
Question 5 : Affirmation : En Python, l'instruction if x = 5 : provoque une erreur.
- (Correct) Vrai
- (Incorrect) Faux
Question 6 : Affirmation : En Python, une condition après if doit obligatoirement être écrite entre parenthèses.
- (Incorrect) Vrai
- (Correct) Faux