Operators

Python ↔ Baobab
10 correspondences

Symbolic operators (+, -, ==, <=, +=…) are identical to Python. Only word operators are translated.

PythonBaobabDescription
+ - * /+ - * /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 / notet / ou / nonBoolean logic.
x in seqx dans seqTrue if x belongs to the sequence.
x not in seqx non dans seqTrue if x does not belong to the sequence.
+= -= *= /= //= %= **=+= -= *= /= //= %= **=Augmented assignments.
a if cond else ba si cond sinon bConditional (ternary) expression.
Complete example — Baobab ↔ Python
Baobab
1
2
3
4
5
6
7
8
9
10
11
12
13
# 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) # → mineur
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
# 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