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

Vrai/Faux : Modules et combinaisons de fonctions (niveau 3)

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 les modules Python et les combinaisons de fonctions, indiquez si elle est Vraie ou Fausse.

Déroulement pas à pas (Correction et Indices)

Question 1 :

On exécute le programme Python ci-dessous :

import math
print(math.sqrt(9))

Affirmation : Ce programme affiche $3{,}0$.

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

On considère l'instruction Python suivante :

from random import randint
x = randint(1, 6)

Affirmation : La variable x peut prendre les valeurs $1, 2, 3, 4$ ou $5$.

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

Affirmation : Après avoir écrit from math import sqrt, on peut utiliser sqrt(25) sans préfixe.

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

On considère le programme Python ci-dessous :

def carre(x) :
    return x*x

def somme_carres(a, b) :
    return carre(a) + carre(b)

print(somme_carres(3, 4))

Affirmation : Ce programme affiche $25$.

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

Affirmation : Pour utiliser la fonction cos du module math sans préfixe, il faut écrire import math.

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

On considère la fonction Python ci-dessous :

from random import randint

def lance_de() :
    nb_six = 0
    for i in range(6) :
        if randint(1, 6) == 6 :
            nb_six = nb_six + 1
    return nb_six

Affirmation : L'appel lance_de() renvoie toujours $1$.

  • (Incorrect) Vrai
  • (Correct) Faux