Operators
Python ↔ Baobab
10 correspondences
Symbolic operators (+, -, ==, <=, +=…) are identical to Python. Only word operators are translated.
| Python | Baobab | Description |
|---|---|---|
| + - * / | + - * / | Basic arithmetic. |
| // | // | Floor division: 7 // 2 is 3. |
| % | % | Modulo (remainder): 7 % 2 is 1. |
| ** | ** | Power: 2 ** 10 is 1024. |
| == != < <= > >= | == != < <= > >= | Comparisons — identical to Python. |
| and / or / not | et / ou / non | Boolean logic. |
| x in seq | x dans seq | True if x belongs to the sequence. |
| x not in seq | x non dans seq | True if x does not belong to the sequence. |
| += -= *= /= //= %= **= | += -= *= /= //= %= **= | Augmented assignments. |
| a if cond else b | a si cond sinon b | Conditional (ternary) expression. |
Complete example — Baobab ↔ Python
Baobab
12345678910111213# Opérateurs en action
a = 7
b = 2
afficher(a / b) # → 3.5
afficher(a // b) # → 3
afficher(a % b) # → 1
afficher(a ** b) # → 49
a += 3 # a vaut 10
afficher(a >= 10 et b < 5) # → vrai
afficher(3 dans [1, 2, 3]) # → vrai
statut = "majeur" si a >= 18 sinon "mineur"
afficher(statut) # → mineurPython
12345678910111213# Operators in action
a = 7
b = 2
print(a / b) # → 3.5
print(a // b) # → 3
print(a % b) # → 1
print(a ** b) # → 49
a += 3 # a is 10
print(a >= 10 and b < 5) # → True
print(3 in [1, 2, 3]) # → True
statut = "majeur" if a >= 18 else "mineur"
print(statut) # → mineur