Hacking Secret Ciphers with Python

(Ann) #1
Chapter 9 – The Transposition Cipher, Decrypting 133

the expression 10 < 5 and the expression 4 != 4 are both False, this makes the second
above expression evaluate to False or False, which in turn evaluates to False.


The third Boolean operator is not. The not operator evaluates to the opposite Boolean value of
the value it operates on. So not True is False and not False is True. Type the following
into the interactive shell:





not 10 > 5
False
not 10 < 5
True
not False
True
not not False
False
not not not not not False
True





Practice Exercises, Chapter 9, Set B


Practice exercises can be found at http://invpy.com/hackingpractice9B.


Truth Tables


If you ever forget how the Boolean operators work, you can look at these charts, which are called
truth tables:


Table 6-1: The and operator's truth table.
A and B is Entire statement
True and True is True
True and False is False
False and True is False
False and False is False

Table 6-2: The or operator's truth table.
A or B is Entire statement
True or True is True
True or False is True
False or True is True
False or False is False
Free download pdf