QCM Langage Python : les fonctions



Python version 2 ou 3
Webographie : http://fsincere.free.fr/isn/python/cours_python_ch4.php



Question 1/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -1 point, je ne sais pas 0 point


def func(a):
    a += 2.0
    return a

a = func(8.0)
print(a)


Qu'affiche le script ?








Question 2/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -0,5 point, je ne sais pas 0 point


def diff(val1,val2):
    return val2 - val1

a = diff(3.0,-2.0)
print(a)


Qu'affiche le script ?









Question 3/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -2 points, je ne sais pas 0 point


def func(val):
    if val<0.0:
        return 0
    return val

a = func(-1.5)
print(a)


Qu'affiche le script ?







Question 4/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -1 point, je ne sais pas 0 point


def carre(val):
    return val*val

def inc(val):
    return val + 1

a = carre(inc(3.0))
print(a)


Qu'affiche le script ?








Question 5/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -0,5 point, je ne sais pas 0 point


def func(a):
    a += 2.0
    return a

a = 5.0
b = func(a)
print(a,b)


Qu'affiche le script ?









Question 6/6 : Python

Barème : bonne réponse 4 points, mauvaise réponse -0,5 point, je ne sais pas 0 point


Une question nettement plus subtile :

def f(x):
    return x

y = f(4)
print(y)
g = f(f)
print(g(2))
f = f(3)
print(f)
print(g(5))
print(f(6))


Qu'affiche le script ?










Retour à la page d'accueil


© Fabrice Sincère ; Version 2.2

Valid XHTML 1.0 Strict CSS Valide !