Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.
saluer("Alice")
def saluer(nom="Invité"):
print(f"Bonjour, {nom}!")
def somme(*nombres):
total = 0
for n in nombres:
total += n
return total
somme(1, 2, 3)
def afficher_infos(**kwargs):
for cle, valeur in kwargs.items():
print(f"{cle}: {valeur}")
afficher_infos(nom="Alice", age=30)
def saluer(nom):
print(f"Bonjour, {nom}!")
def addition(a, b):
return a + b
resultat = addition(5, 3)
carre = lambda x: x * x
print(carre(5))
x = 10 # Globale
def ma_fonction():
y = 5 # Locale
print(x)
x = 10
def modifier_global():
global x
x = 20