Introducing Boolean algebra in programming - Answers
Q1. For each of the following, state whether the answer is TRUE or FALSE.
a. 10 > 20 FALSE
b. 20 < 40 TRUE
c. 10 >=10 TRUE
d. 5 <= 9 TRUE
e. 34 == 31 FALSE
f. 23 != 45 TRUE
g. 17 >= 50 FALSE
h. 45 != 45 FALSE
Q2. For each of the following, state whether the answer is TRUE or FALSE and explain how you arrived at your answer.
a. "Jack" > "Jill" FALSE because the ASCII code for a is 97 and the ASCII code for i is 105. 97 > 105 is FALSE.
b. "Kevin" < "kevin" TRUE because the ASCII code for K is 75 and the ASCII code for k is 107. 75 < 107 is TRUE.
c. "Door" > "Doormouse" FALSE because the ASCII code for null is 0 and the ASCII code for m is 109. 0 > 109 is FALSE.
d. "A work of art" < "All is not well". TRUE because the ASCII code for null is 0 and the ASCII code for l is 108. 0 < 108 is TRUE.
e. "Blue and green" > "Blue and red" FALSE because the ASCII code for g is 103 and the ASCII code for r is 114. 103 > 114 is FALSE.