Aller au contenu

QCM

Rappel

Les questions ci-dessous sont là pour vous aider à contrôler ce que vous avez retenu.
Si vous ne répondez pas à toutes les questions sans hésitation, c'est sans doute qu'il faut retravailler les pages précédentes.

Pour chaque question, il faut trouver la (ou les) bonne(s) réponse(s).

QCM 1

Voici la table de vérité d'une fonction nommée multiplexeur :

a b c mux(a, b, c)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1

Laquelle des expressions lui correspond:

  • (not(a) and b) or (a and c)
  • (a and b) or (not(a) and c)
  • (not(a) or b) and (a or c)
  • b or (a and c)
Réponse
  • (not(a) and b) or (a and c)
  • (a and b) or (not(a) and c)
  • (not(a) or b) and (a or c)
  • b or (a and c)

QCM 2

Pour dresser une table de vérité, on utilise la valeur 1 pour True et 0 pour False. Laquelle des fonctions suivantes ne correspond pas à une fonction ou :

  • 1
    2
    def f(a, b):
        return a+b-a*b
    
  • 1
    2
    def g(a, b):
        return max(a,b)
    
  • 1
    2
    def h(a, b):
        return 1 - (1-a)*(1-b)
    
  • 1
    2
    def k(a, b):
        (a+b)%2
    
Réponse
  • 1
    2
    def f(a, b):
        return a+b-a*b
    
  • 1
    2
    def g(a, b):
        return max(a,b)
    
  • 1
    2
    def h(a, b):
        return 1 - (1-a)*(1-b)
    
  • 1
    2
    def k(a, b):
        (a+b)%2
    

QCM 3

On considère la fonction suivante :

1
2
3
4
def table():
    for a in (False, True):
        for b in (False, True):
            print((a or b) and a)

On effectue l'appel suivant dans la console :

>>> table()

La console affiche :

  • False
    False
    True
    True
    

  • False
    True
    False
    True
    

  • True
    False
    True
    False
    

  • True
    True
    False
    False
    

Réponse
  • False
    False
    True
    True
    

  • False
    True
    False
    True
    

  • True
    False
    True
    False
    

  • True
    True
    False
    False
    

Pour bien comprendre la réponse, on peut dresser la table de vérité de l'expression (a ou b) et a :

a b a or b (a or b) and a
0 0 0 0
0 1 1 0
1 0 1 1
1 1 1 1

QCM 4

Pour deux booléens x et y, on définit l'opération « x ↑ y » par : x ↑ y = non( x et y) (opération appelée barre de Sheffer).

Une autre expression de (x ↑ y) ↑ (x ↑ y) est:

  • x ou y
  • x et y
  • non(x et y)
  • non(x ou y)
Réponse
  • x ou y
  • x et y
  • non(x et y)
  • non(x ou y)

La table de vérité est en effet la suivante :

a b a et b a ↑ b = non(a et b) (a ↑ b) et (a ↑ b) (a ↑ b) ↑ (a ↑ b) = non((a ↑ b) et (a ↑ b))
0 0 0 1 1 0
0 1 0 1 1 0
1 0 0 1 1 0
1 1 1 0 0 1

QCM 5

L'expression (a ou b) et a est égale à:

  • a ou b
  • b
  • a
  • a xor b
Réponse
  • a ou b
  • b
  • a
  • a xor b

Pour bien comprendre la réponse, dresser la table de vérité de l'expression (a ou b) et a :

a b a ou b (a ou b) et a
0 0 0 0
0 1 1 0
1 0 1 1
1 1 1 1

QCM 6

Pour deux booléens x et y, on définit l'opération « x → y » par : x → y = non(x) ou y (opération appelée implication).

Une autre expression de ((x → y) et x) → y est:

  • x et x
  • x ou non(x)
  • x et non(x)
  • x
Réponse
  • x et x
  • x ou non(x)
  • x et non(x)
  • x et non(y)

La table de vérité de ((x → y) et x) → y est en effet la suivante :

x y non(x) x→y  =  non(x) ou y (x→y) et x non((x→y) et x) ((x → y) et x) → y = non((x→y) et x) ou y
0 0 1 1 0 1 1
0 1 1 1 0 1 1
1 0 0 0 0 1 1
1 1 0 1 1 0 1

et la table de x ou non(x) est :

x y non(x) x ou non(x)
0 0 1 1
0 1 1 1
1 0 0 1
1 1 0 1