%%tutor -l python3 -s -h 600
non_mutable = "pas touche"
def call_me(non_mutable):
non_mutable = "touché"
print(f"Dans le corps de la fonction {non_mutable}")
call_me(non_mutable)
print(f"Mais à l'extérieur {non_mutable}")
%%tutor -l python3 -h 600 -s
mutable = ["attrape", "moi"]
def appelle_moi(mutable):
mutable += [" si tu peux"]
print(f"Dans le corps de la fonction {mutable}")
appelle_moi(mutable)
print(f"Et à l'extérieur {mutable}")
%%tutor -l python3 -s -h 600
mutable = ["attrape", "moi"]
def appelle_moi_autrement(mutable):
mutable = mutable + [" si tu peux"]
print(f"Dans le corps de la fonction {mutable}")
appelle_moi_autrement(mutable)
print(f"Et à l'extérieur {mutable}")
%%tutor -l python3 -s -h 600
mutable = ["attrappe", "moi"]
def appelle_moi(mutable):
mutable.append(" si tu peux")
print(f"Dans le corps de la fonction {mutable}. id = {id(mutable)}")
appelle_moi(mutable)
print(f"Et à l'extérieur {mutable}. id = {id(mutable)}")
mutable = ["attrappe", "moi"]
def appelle_moi_autrement(mutable):
mutable = mutable + [" si tu peux"]
print(f"Dans le corps de la fonction {mutable}. id = {id(mutable)}")
appelle_moi_autrement(mutable)
print(f"Et à l'extérieur {mutable}. id = {id(mutable)}")
%%tutor -l python3 -s -h 600
def appelle_moi_autrement():
paramètre = liste
paramètre.append(" si tu peux")
liste = ["attrape", "moi"]
appelle_moi_autrement()
%%tutor -l python3 -s -h 600
def appelle_moi_autrement():
paramètre = liste
paramètre = paramètre + [" si tu peux"]
liste = ["attrape", "moi"]
appelle_moi_autrement()