Gallery
Learn by remixing real projects.
Open any example in the Playground and tweak it live. No setup, no signup.
Calculator
Beginner
A REPL-style calculator covering arithmetic, variables and conditions.
15 min
Todo App
Beginner
Track tasks with add, complete and delete. Touches lists and dictionaries.
25 min
Weather App
Intermediate
Fetch and parse weather data, render a small text dashboard.
30 min
School Management
Intermediate
Manage students, classes and grades using Baobab classes and modules.
45 min
Bank System
Intermediate
Accounts, deposits, withdrawals and transfers with validation logic.
1 h
Chat Application
Advanced
Build a small chat with rooms, messages and timestamps.
1 h 15
Library (multi-file)
Advanced
A real multi-file project: a Livre and a Bibliotheque class split across modules, wired together with imports.
1 h 30 3 files
Source preview
Side-by-side: Baobab ↔ Python
Every example translates between Baobab and Python. Click any card above to open it in the Playground.
Calculator
Open in PlaygroundBaobab · calculator.bao
BAO
12345678910111213141516171819202122232425262728# calculator.bao — calculatrice simple
fonction calculer(a, op, b):
si op == "+":
retourner a + b
sinonsi op == "-":
retourner a - b
sinonsi op == "*":
retourner a * b
sinonsi op == "/":
si b == 0:
afficher("Erreur: division par zero")
retourner nul
retourner a / b
sinon:
afficher("Opération inconnue: " + op)
retourner nul
fonction principale():
afficher("=== Calculatrice Baobab ===")
afficher("4 + 5 = " + texte(calculer(4, "+", 5)))
afficher("10 - 3 = " + texte(calculer(10, "-", 3)))
afficher("6 * 7 = " + texte(calculer(6, "*", 7)))
afficher("20 / 4 = " + texte(calculer(20, "/", 4)))
calculer(1, "%", 2)
retourner 0
principale()
Python · calculator.py
PY
12345678910111213141516171819202122232425262728# calculator.py — simple calculator
def calculer(a, op, b):
if op == "+":
return a + b
elif op == "-":
return a - b
elif op == "*":
return a * b
elif op == "/":
if b == 0:
print("Erreur: division par zero")
return None
return a / b
else:
print("Opération inconnue: " + op)
return None
def principale():
print("=== Calculatrice Baobab ===")
print("4 + 5 = " + str(calculer(4, "+", 5)))
print("10 - 3 = " + str(calculer(10, "-", 3)))
print("6 * 7 = " + str(calculer(6, "*", 7)))
print("20 / 4 = " + str(calculer(20, "/", 4)))
calculer(1, "%", 2)
return 0
principale()
Todo App
Open in PlaygroundBaobab · todo.bao
BAO
123456789101112131415161718192021222324# todo.bao — gestionnaire de tâches
taches = []
fonction ajouter(titre):
taches.ajouter({ "titre": titre, "fait": faux })
fonction terminer(index):
taches[index]["fait"] = vrai
afficher("Tâche " + texte(index + 1) + " terminée.")
fonction afficher_liste():
afficher("📋 Mes tâches:")
pour i dans intervalle(longueur(taches)):
t = taches[i]
marque = "[x]" si t["fait"] sinon "[ ]"
afficher(marque + " " + texte(i + 1) + ". " + t["titre"])
ajouter("Apprendre Baobab")
ajouter("Construire une app")
ajouter("Partager avec la communauté")
afficher_liste()
terminer(0)
afficher_liste()
Python · todo.py
PY
123456789101112131415161718192021222324# todo.py — task manager
taches = []
def ajouter(titre):
taches.append({ "titre": titre, "fait": False })
def terminer(index):
taches[index]["fait"] = True
print("Tâche " + str(index + 1) + " terminée.")
def afficher_liste():
print("📋 Mes tâches:")
for i in range(len(taches)):
t = taches[i]
marque = "[x]" if t["fait"] else "[ ]"
print(marque + " " + str(i + 1) + ". " + t["titre"])
ajouter("Apprendre Baobab")
ajouter("Construire une app")
ajouter("Partager avec la communauté")
afficher_liste()
terminer(0)
afficher_liste()
School Management
Open in PlaygroundBaobab · school.bao
BAO
123456789101112131415161718192021222324252627# school.bao — gestion des étudiants
classe Etudiant:
fonction nouveau(nom, notes):
ce.nom = nom
ce.notes = notes
fonction moyenne():
total = 0
pour n dans ce.notes:
total = total + n
retourner total / longueur(ce.notes)
etudiants = [
nouveau Etudiant("Amina", [16, 14, 16.5]),
nouveau Etudiant("Kofi", [10, 13, 13]),
nouveau Etudiant("Fatou", [18, 17, 16.5]),
]
afficher("🎓 École Baobab")
meilleur = etudiants[0]
pour e dans etudiants:
afficher(e.nom + " — moyenne: " + texte(e.moyenne()))
si e.moyenne() > meilleur.moyenne():
meilleur = e
afficher("Meilleur: " + meilleur.nom)
Python · school.py
PY
123456789101112131415161718192021222324252627# school.py — student management
class Etudiant:
def __init__(self, nom, notes):
self.nom = nom
self.notes = notes
def moyenne(self):
total = 0
for n in self.notes:
total = total + n
return total / len(self.notes)
etudiants = [
Etudiant("Amina", [16, 14, 16.5]),
Etudiant("Kofi", [10, 13, 13]),
Etudiant("Fatou", [18, 17, 16.5]),
]
print("🎓 École Baobab")
meilleur = etudiants[0]
for e in etudiants:
print(e.nom + " — moyenne: " + str(e.moyenne()))
if e.moyenne() > meilleur.moyenne():
meilleur = e
print("Meilleur: " + meilleur.nom)
Bank System
Open in PlaygroundBaobab · bank.bao
BAO
12345678910111213141516171819202122232425262728293031323334353637# bank.bao — système bancaire
classe Compte:
fonction nouveau(titulaire, solde):
ce.titulaire = titulaire
ce.solde = solde
fonction deposer(montant):
si montant <= 0:
afficher("Montant invalide")
retourner faux
ce.solde = ce.solde + montant
afficher("Dépôt: +" + texte(montant) + " → " + texte(ce.solde))
retourner vrai
fonction retirer(montant):
si montant > ce.solde:
afficher("Solde insuffisant")
retourner faux
ce.solde = ce.solde - montant
afficher("Retrait: -" + texte(montant) + " → " + texte(ce.solde))
retourner vrai
fonction transferer(autre, montant):
si ce.retirer(montant):
autre.deposer(montant)
afficher("Transfert " + ce.titulaire + " → " + autre.titulaire + ": " + texte(montant))
afficher("🏦 Banque Baobab")
amina = nouveau Compte("Amina", 500)
kofi = nouveau Compte("Kofi", 0)
afficher("Compte Amina: " + texte(amina.solde))
amina.deposer(250)
amina.retirer(100)
amina.transferer(kofi, 200)
afficher("Compte Amina: " + texte(amina.solde))
afficher("Compte Kofi: " + texte(kofi.solde))
Python · bank.py
PY
12345678910111213141516171819202122232425262728293031323334353637# bank.py — banking system
class Compte:
def __init__(self, titulaire, solde):
self.titulaire = titulaire
self.solde = solde
def deposer(self, montant):
if montant <= 0:
print("Montant invalide")
return False
self.solde = self.solde + montant
print("Dépôt: +" + str(montant) + " → " + str(self.solde))
return True
def retirer(self, montant):
if montant > self.solde:
print("Solde insuffisant")
return False
self.solde = self.solde - montant
print("Retrait: -" + str(montant) + " → " + str(self.solde))
return True
def transferer(self, autre, montant):
if self.retirer(montant):
autre.deposer(montant)
print("Transfert " + self.titulaire + " → " + autre.titulaire + ": " + str(montant))
print("🏦 Banque Baobab")
amina = Compte("Amina", 500)
kofi = Compte("Kofi", 0)
print("Compte Amina: " + str(amina.solde))
amina.deposer(250)
amina.retirer(100)
amina.transferer(kofi, 200)
print("Compte Amina: " + str(amina.solde))
print("Compte Kofi: " + str(kofi.solde))
Weather App
Open in PlaygroundBaobab · weather.bao
BAO
1234567891011121314# weather.bao — tableau météo
jours = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"]
temperatures = [28, 26, 24, 27, 30]
icones = ["☀️", "⛅", "🌧️", "☀️", "☀️"]
afficher("🌤️ Météo de la semaine")
total = 0
pour i dans intervalle(longueur(jours)):
afficher(jours[i] + ": " + texte(temperatures[i]) + "°C " + icones[i])
total = total + temperatures[i]
moyenne = total / longueur(jours)
afficher("Moyenne: " + texte(moyenne) + "°C")
Python · weather.py
PY
1234567891011121314# weather.py — weather dashboard
jours = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"]
temperatures = [28, 26, 24, 27, 30]
icones = ["☀️", "⛅", "🌧️", "☀️", "☀️"]
print("🌤️ Météo de la semaine")
total = 0
for i in range(len(jours)):
print(jours[i] + ": " + str(temperatures[i]) + "°C " + icones[i])
total = total + temperatures[i]
moyenne = total / len(jours)
print("Moyenne: " + str(moyenne) + "°C")
Chat Application
Open in PlaygroundBaobab · chat.bao
BAO
1234567891011121314151617181920212223242526272829303132333435# chat.bao — application de messagerie
classe Message:
fonction nouveau(auteur, contenu, heure):
ce.auteur = auteur
ce.contenu = contenu
ce.heure = heure
classe Salon:
fonction nouveau(nom):
ce.nom = nom
ce.messages = []
ce.utilisateurs = []
fonction rejoindre(utilisateur):
ce.utilisateurs.ajouter(utilisateur)
fonction envoyer(auteur, contenu, heure):
ce.messages.ajouter(nouveau Message(auteur, contenu, heure))
fonction afficher_tout():
afficher("💬 Salon: #" + ce.nom)
pour m dans ce.messages:
afficher("[" + m.heure + "] " + m.auteur + ": " + m.contenu)
afficher(texte(longueur(ce.utilisateurs)) + " utilisateurs · " + texte(longueur(ce.messages)) + " messages")
general = nouveau Salon("général")
general.rejoindre("Amina")
general.rejoindre("Kofi")
general.rejoindre("Fatou")
general.envoyer("Amina", "Salut tout le monde!", "09:01")
general.envoyer("Kofi", "Bonjour Amina 👋", "09:02")
general.envoyer("Fatou", "On code en Baobab aujourd'hui?", "09:03")
general.envoyer("Amina", "Oui, hâte de commencer!", "09:04")
general.afficher_tout()
Python · chat.py
PY
1234567891011121314151617181920212223242526272829303132333435# chat.py — chat application
class Message:
def __init__(self, auteur, contenu, heure):
self.auteur = auteur
self.contenu = contenu
self.heure = heure
class Salon:
def __init__(self, nom):
self.nom = nom
self.messages = []
self.utilisateurs = []
def rejoindre(self, utilisateur):
self.utilisateurs.append(utilisateur)
def envoyer(self, auteur, contenu, heure):
self.messages.append(Message(auteur, contenu, heure))
def afficher_tout(self):
print("💬 Salon: #" + self.nom)
for m in self.messages:
print("[" + m.heure + "] " + m.auteur + ": " + m.contenu)
print(str(len(self.utilisateurs)) + " utilisateurs · " + str(len(self.messages)) + " messages")
general = Salon("général")
general.rejoindre("Amina")
general.rejoindre("Kofi")
general.rejoindre("Fatou")
general.envoyer("Amina", "Salut tout le monde!", "09:01")
general.envoyer("Kofi", "Bonjour Amina 👋", "09:02")
general.envoyer("Fatou", "On code en Baobab aujourd'hui?", "09:03")
general.envoyer("Amina", "Oui, hâte de commencer!", "09:04")
general.afficher_tout()
Library (multi-file)
Open in PlaygroundBaobab · livre.bao
BAO
12345678910111213# livre.bao — un livre et son état d'emprunt
classe Livre:
fonction nouveau(titre, auteur):
ce.titre = titre
ce.auteur = auteur
ce.disponible = vrai
fonction emprunter():
si non ce.disponible:
retourner faux
ce.disponible = faux
retourner vrai
Python · livre.py
PY
12345678910111213# livre.py — un livre et son état d'emprunt
class Livre:
def __init__(self, titre, auteur):
self.titre = titre
self.auteur = auteur
self.disponible = True
def emprunter(self):
if not self.disponible:
return False
self.disponible = False
return True
Baobab · bibliotheque.bao
BAO
12345678910111213141516171819# bibliotheque.bao — une collection de livres
importer livre depuis "./livre.bao"
classe Bibliotheque:
fonction nouveau(nom):
ce.nom = nom
ce.livres = []
fonction ajouter(titre, auteur):
ce.livres.ajouter(livre.Livre(titre, auteur))
fonction emprunter(titre):
pour l dans ce.livres:
si l.titre == titre:
si l.emprunter():
retourner "Emprunt de " + titre
retourner titre + " est deja emprunte"
retourner titre + " introuvable"
Python · bibliotheque.py
PY
12345678910111213141516171819# bibliotheque.py — une collection de livres
import livre
class Bibliotheque:
def __init__(self, nom):
self.nom = nom
self.livres = []
def ajouter(self, titre, auteur):
self.livres.append(livre.Livre(titre, auteur))
def emprunter(self, titre):
for l in self.livres:
if l.titre == titre:
if l.emprunter():
return "Emprunt de " + titre
return titre + " est deja emprunte"
return titre + " introuvable"
Baobab · main.bao
BAO
1234567891011# main.bao — point d'entrée du programme
importer bibliotheque depuis "./bibliotheque.bao"
biblio = bibliotheque.Bibliotheque("Centrale")
biblio.ajouter("Le Petit Prince", "Saint-Exupery")
biblio.ajouter("1984", "Orwell")
afficher(biblio.emprunter("1984"))
afficher(biblio.emprunter("1984"))
afficher(biblio.emprunter("Inconnu"))
Python · main.py
PY
1234567891011# main.py — point d'entrée du programme
import bibliotheque
biblio = bibliotheque.Bibliotheque("Centrale")
biblio.ajouter("Le Petit Prince", "Saint-Exupery")
biblio.ajouter("1984", "Orwell")
print(biblio.emprunter("1984"))
print(biblio.emprunter("1984"))
print(biblio.emprunter("Inconnu"))