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 :
- à la main,
- puis à l'aide d'un programme python.
a, b et c désignent trois booléens. Dresser la table de vérité de (a and b) or c :
a | b | c | a and b | (a and b) or c |
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 1 |
0 | 1 | 0 | 0 | 0 |
0 | 1 | 1 | 0 | 1 |
1 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 1 |
1 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 1 |
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.
a, b et c désignent trois booléens. Dresser la table de vérité de a and (b or c) :
a | b | c | b or c | a and (b or c) |
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 0 |
0 | 1 | 0 | 1 | 0 |
0 | 1 | 1 | 1 | 0 |
1 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 1 | 1 |
1 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 1 |
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.