Conditions

A conditional runs a block depending on whether an expression is true or false. si / sinonsi / sinon map to if / elif / else. Each test ends with : and its block is indented.

1
2
3
4
5
6
7
age = 15 si age >= 18: afficher("Adulte") sinonsi age >= 13: afficher("Adolescent") sinon: afficher("Enfant")
Adolescent

Comparisons are written ==, !=, <, >, <=, >=. Combine several conditions with the logical operators et, ou, non (Python: and, or, not).

1
2
3
4
connecte = vrai admin = faux si connecte et non admin: afficher("Accès limité")
Accès limité

sinonsi and sinon are optional: a lone si is enough, and you can chain as many sinonsi as needed.