Les booléens

Une table de vérité.

a, b et c désignent trois booléens. Dresser la table de vérité de (a and b) or c :

  1. à la main,
  2. puis à l'aide d'un programme python.

Résolution de l'exercice "Une table de vérité.".

abca and b(a and b) or c
00000
00101
01000
01101
10000
10101
11011
11111

Code python pour générer la table :


for a in (0,1) :
	for b in (0,1) :
		for c in (0, 1) :
			print( " ({} and {}) or {} = {}.".format(a,b,c,(a and b) or c ) )
(0 and 0) or 0 = 0.
 (0 and 0) or 1 = 1.
 (0 and 1) or 0 = 0.
 (0 and 1) or 1 = 1.
 (1 and 0) or 0 = 0.
 (1 and 0) or 1 = 1.
 (1 and 1) or 0 = 1.
 (1 and 1) or 1 = 1.

Une autre table de vérité.

a, b et c désignent trois booléens. Dresser la table de vérité de a and (b or c) :

  1. à la main,
  2. puis à l'aide d'un programme python.

Résolution de l'exercice "Une autre table de vérité.".

abcb or ca and (b or c)
00000
00110
01010
01110
10000
10111
11011
11111

Code python pour générer la table :


for a in (0,1) :
	for b in (0,1) :
		for c in (0, 1) :
			print( " {} and ({} or {}) = {}.".format(a,b,c,a and (b or c) ) )
0 and (0 or 0) = 0.
0 and (0 or 1) = 0.
0 and (1 or 0) = 0.
0 and (1 or 1) = 0.
1 and (0 or 0) = 0.
1 and (0 or 1) = 1.
1 and (1 or 0) = 1.
1 and (1 or 1) = 1.