Python au lycée (4) : Les fonctions Entraînement

Vrai/Faux : return, print et fonctions par morceaux (niveau 2)

Durée estimée
5 minutes
Difficulté
Votre progression

Créez un compte gratuit pour suivre votre avancement et reprendre où vous avez laissé.

Créer un compte

Objectifs travaillés

Pour chaque affirmation suivante sur return, print et les fonctions mathématiques Python, indiquez si elle est Vraie ou Fausse.

Déroulement pas à pas (Correction et Indices)

Question 1 :

On considère le programme Python ci-dessous :

def carre(x) :
    print(x*x)

a = carre(5)
print(a)

Affirmation : Ce programme affiche $25$ puis $25$.

  • (Incorrect) Vrai
  • (Correct) Faux
Question 2 :

On considère le programme Python ci-dessous :

def carre(x) :
    return x*x

a = carre(5)
print(a + 1)

Affirmation : Ce programme affiche $26$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 3 :

On considère la fonction moyenne ci-dessous :

def moyenne(a, b, c) :
    m = (a + b + c) / 3
    return m

Affirmation : L'appel moyenne(10, 12, 14) renvoie $12{,}0$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 4 :

On considère la fonction Python ci-dessous :

def f(x) :
    if x <= 0 :
        return -x + 1
    else :
        return 3*x + 1

Affirmation : L'appel f(5) renvoie $16$.

  • (Correct) Vrai
  • (Incorrect) Faux
Question 5 :

On considère la fonction Python ci-dessous :

def f(x) :
    if x <= 0 :
        return -x + 1
    else :
        return 3*x + 1

Affirmation : L'appel f(-3) renvoie $-8$.

  • (Incorrect) Vrai
  • (Correct) Faux
Question 6 :

On considère la fonction Python ci-dessous :

def test(x) :
    return x > 10

print(test(7))

Affirmation : Ce programme affiche True.

  • (Incorrect) Vrai
  • (Correct) Faux