Exécuter les programmes suivants en version papier

Exercice 1

def fonction2(a,b=3):
    b=a-b
    return b
print(fonction2(3,1))
print(fonction2(a=2))

lien pythontutor

Exercice 2

def fonction1(a, b):
    print(a, b)
    a += b
    return a
a, b = 3, 2
print(fonction1(a,b), a, b)

lien pythontutor

Exercice 3

def coucou(a, b=2):
    a += b
    return a
def cuicui(c):
    c = coucou(c)
    return c
print(cuicui(3))

lien pythontutor

Exercice 4

def g(a):
    return 3*a
def f(b):
    return 2*b
print(g(f(g(2))))

lien pythontutor

Exercice 5

def g(a):
    print(a)
    return a
def h(a):
    print(g(a))
    return 2*a
def w(a):
    print(g(h(a)))
print(w(1))

lien pythontutor

Exercice 6

def k(x):
    print(2*x)
    return x
def z(b):
    b = 2*b
    print(k(b))
    return b
def p(c):
    print(2*z(c))
    return c
print(p(1))

lien pythontutor