What value does the Python expression 2 + 3 * 4 produce?
03. Expressions and Boolean Logic Online Quiz Questions
Use this free practice quiz with 20 questions to review 03. Expressions and Boolean Logic, test your knowledge, and prepare for your next test or exam.
In Python, x = 10 asks whether x already equals 10.
- A
True
- B
False
What numeric value does the Python expression 20 / 5 * 2 produce? Enter the numeric value only. No tolerance is allowed.
In the expression 7 % 2, the result is the after division.
What value does the Python expression "-" * 5 produce?
- A
"-5"
- B
"-----"
- C
5
- D
An error because strings cannot use
*
Which three values are false in a Python Boolean context? Select all correct choices.
- A
False - B
"hello" - C
0 - D
"" - E
[1]
Python's and and or operators always return either True or False, never an operand such as a string.
- A
True
- B
False
What numeric value does the Python expression 2 ** 3 ** 2 produce? Enter the numeric value only. No tolerance is allowed.
In number != 0 and 100 / number > 2, the division is skipped when number is zero because of .
Which expression is equivalent to the Python chained comparison 10 <= score <= 20?
- A
10 <= score and score <= 20 - B
10 <= (score <= 20) - C
10 < score < 20only - D
score <= 10 or score >= 20
Which three expressions are valid examples of the string operations described in the material? Select all correct choices.
- A
"a" + "b" - B
"a" + 3 - C
f"Score: {95}" - D
"a" * "b" - E
"cat" in "concatenate"
Explain how the expression number != 0 and 100 / number > 2 prevents a division-by-zero error. Include the evaluation order and the role of short-circuiting.
Which statement about the Python string comparison "A" < "a" is correct?
- A
"apple" < "banana"is false - B
"A" < "a"is true - C
"apple" < "banana"raises an error - D
String comparisons ignore letter case
In Python, what is the result of evaluating bool([])?
- A
True
- B
False
- C
None
- D
It raises a TypeError
Given name = "Ada" and score = 95, what string does f"{name} scored {score}%" produce?
- A
Ada scored {score}% - B
name scored 95% - C
Ada scored 95% - D
Ada scored score%
What is the result of this Python code?
score = 15
10 <= score <= 20
- A
True - B
False - C
15 - D
A syntax error
What happens when number = 0 and Python evaluates number != 0 and 100 / number > 2?
- A
True - B
A division-by-zero error
- C
False - D
0
True or false: In Python, 2 ** 3 ** 2 evaluates to 512.
- A
True
- B
False
What numeric value does the Python expression 20 / 5 * 2 produce?
In Python, what numeric value does the expression 29 // 6 produce?