Variables & basic types
Python ↔ Baobab
11 correspondences
Dynamic typing like Python. Conversion functions have French names; type_de() plays the role of type().
| Python | Baobab | Description |
|---|---|---|
| int(x) | entier(x) | Convert to integer. |
| float(x) | decimal(x) | Convert to floating-point number. |
| str(x) | texte(x) | Convert to string. |
| bool(x) | booleen(x) | Convert to boolean (vrai/faux). |
| list(x) | liste(x) | Convert an iterable to a list. |
| tuple(x) | tuple(x) | Convert to a tuple (immutable sequence). |
| set(x) | ensemble(x) | Convert to a set (unique elements). |
| dict(...) | dictionnaire(...) | Create a key → value dictionary. |
| type(x) | type_de(x) | Return the value's type. |
| isinstance(x, T) | est_instance(x, T) | Test whether x is an instance of type T. |
| ord(c) / chr(n) | code(c) / caractere(n) | Unicode code point of a character and back. |
Complete example — Baobab ↔ Python
Baobab
123456789101112# Types dynamiques et conversions
age = 17 # entier
prix = 9.99 # decimal
nom = "Aminata" # texte
actif = vrai # booleen
afficher(type_de(age)) # → <classe 'entier'>
afficher(entier("42") + 1) # → 43
afficher(texte(age) + " ans")# → 17 ans
afficher(decimal("3.14")) # → 3.14
afficher(booleen(0)) # → faux
afficher(est_instance(age, entier)) # → vraiPython
123456789101112# Dynamic types and conversions
age = 17 # int
prix = 9.99 # float
nom = "Aminata" # str
actif = True # bool
print(type(age)) # → <class 'int'>
print(int("42") + 1) # → 43
print(str(age) + " ans") # → 17 ans
print(float("3.14")) # → 3.14
print(bool(0)) # → False
print(isinstance(age, int)) # → True