Questions: Logical Operators and Boolean Algebra

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

In Python, what does `False and some_function()` evaluate to, assuming Python uses short-circuit evaluation?

AThe return value of some_function(), because AND always evaluates both operands to determine the result
BFalse, and some_function() is never called
CTrue, because short-circuit evaluation optimizes compound expressions to True when possible
DAn error, because False cannot be the first operand in an AND expression
Question 2 Multiple Choice

Which expression is equivalent to `a OR b AND c`, following standard operator precedence?

A`(a OR b) AND c`
B`a OR (b AND c)`
C`(a AND c) OR b`
D`NOT(NOT a AND NOT b) AND c`
Question 3 True / False

The boolean expression NOT (x AND y) is logically equivalent to (NOT x) AND (NOT y).

TTrue
FFalse
Question 4 True / False

In Python, the expression `len(lst) > 0 and lst[0] == target` is safe to use when lst might be empty, because short-circuit evaluation prevents accessing lst[0] when the list is empty.

TTrue
FFalse
Question 5 Short Answer

Explain how short-circuit evaluation in AND makes the pattern `if collection is not empty and collection[0] == value` safe to use without a separate nested check.

Think about your answer, then reveal below.