Conditions

Python ↔ Baobab
7 correspondences

si / sinonsi / sinon mirror if / elif / else, with the same indentation rule and the same colon.

PythonBaobabDescription
if cond:si cond:Branch executed when the condition is true.
elif cond:sinonsi cond:Alternative condition tested next.
else:sinon:Default branch.
if a and b or not c:si a et b ou non c:Combining logical operators.
a if cond else ba si cond sinon bOne-expression ternary.
if x in liste:si x dans liste:Membership condition.
if not liste:si non liste:True when the list is empty (falsy values).
Complete example — Baobab ↔ Python
Baobab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
age = 17 permis = faux si age >= 18 et permis: afficher("Peut conduire") sinonsi age >= 18: afficher("Doit passer le permis") sinon: afficher("Trop jeune") # ← exécuté categorie = "adulte" si age >= 18 sinon "mineur" afficher(categorie) # → mineur panier = [] si non panier: afficher("Panier vide") # ← exécuté
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
age = 17 permis = False if age >= 18 and permis: print("Peut conduire") elif age >= 18: print("Doit passer le permis") else: print("Trop jeune") # ← executed categorie = "adulte" if age >= 18 else "mineur" print(categorie) # → mineur panier = [] if not panier: print("Panier vide") # ← executed