Functions

A function groups a sequence of statements under a reusable name. You declare it with fonction (Python: def) and return a result with retourner (Python: return). The body is delimited by indentation.

1
2
3
4
5
fonction additionner(a, b): retourner a + b resultat = additionner(3, 4) afficher(resultat)
7

A function that never runs retourner returns nul (Python: None). You can also return several values separated by commas.

Default parameters

1
2
3
4
5
fonction saluer(nom, politesse="Bonjour"): retourner politesse + " " + nom afficher(saluer("Aminata")) afficher(saluer("Kofi", "Salut"))
Bonjour Aminata Salut Kofi

Functions are first-class values: you can store one in a variable, pass it as an argument, or return it from another function — exactly like in Python.