1. Suppose that x and y are variables whose values are numbers. Consider the following expression: x < y. The value of the expression might be:
a. 1~
b. 0~
c. True~
d. False~
e. true
f. false
g. 'true'
h. 'false'
2. Suppose that x and yx are variables whose values are integers. Match the desired behavior to the correct boolean expression.
M. True when both are zero -> (x == 0) and (y == 0)
M. True when at least one is zero -> (x == 0) or (y == 0)
M. True when exactly one is zero -> (x == 0) != (y == 0)
M. True when neither of them is zero -> (x != 0) and (y != 0)
M. -> (x != 0) or (y != 0)
M. -> (x = 0) and (y = 0)
3. If frozen is a variable whose value is a Boolean value, not not frozen is equivalent to frozen.
a. True~
b. False
4. Why would you choose to use a boolean value rather than an integer (e.g., 0 or 1) or string (e.g., 'False' and 'True')?
a. It makes it easier for others to understand your code.~
b. Boolean operators can only be used on boolean values.
c. A string or integer cannot be compared to a boolean value, so complicated expressions cannot be evaluated (e.g., (x > y) and y > z would not work if x, y, and z were not all boolean values).
5. Suppose that b = False and x = 3. Match the statement to its value.
M. b and (x == 3) -> False
M. b and (x == 4) -> False
M. b or (x == 3) -> True
M. b or (x == 4) -> False
M. (not b) and (x == 3) -> True
M. (not b) or (x == 3) -> True
M. b and (x != 3) -> False
M. b or (x != 3) -> True
M. b and (x != 4) -> False
M. b or (x != 4) -> False
M. (not b) and (x != 3) -> True
M. (not b) or (x != 3) -> True
6. Consider the statement shown. Choose an equivalent single-line statement.TODO
7. What is the value of (1 + 2) == 3?
a. True~
b. False
c. Difficult to say for sure
7. What is the value of (0.1 + 0.2) == 0.3?
a. True
b. False~
c. Difficult to say for sure
7. What is the value of (math.sin(math.pi)) == 0?
a. True
b. False~
c. Difficult to say for sure
7. What is the value of (1 / 10) + (9 / 10) == 1?
a. True~
b. False
c. Difficult to say for sure
7. What is the value of (3 // 1) == (9 // 3)?
a. True~
b. False
c. Difficult to say for sure
7. What is the value of x > y or x <= y? Assume x and y are arbitrary integers.
a. True~
b. False
c. Difficult to say for sure
7. What is the value of not (x > y and y > z) or x > z? Assume x, y, and z are arbitrary integers.
a. True
b. False
c. Difficult to say for sure~