Free Practice Quiz Question List

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.

20 questions
01
Choose one
1 point

What value does the Python expression 2 + 3 * 4 produce?

  1. A

    20

  2. B

    14

  3. C

    24

  4. D

    10

02
True or false
1 point

In Python, x = 10 asks whether x already equals 10.

  1. A

    True

  2. B

    False

03
Written response
1 point

What numeric value does the Python expression 20 / 5 * 2 produce? Enter the numeric value only. No tolerance is allowed.

04
Fill in the blank
1 point

In the expression 7 % 2, the result is the after division.

05
Choose one
1 point

What value does the Python expression "-" * 5 produce?

  1. A

    "-5"

  2. B

    "-----"

  3. C

    5

  4. D

    An error because strings cannot use *

06
Choose all
1 point

Which three values are false in a Python Boolean context? Select all correct choices.

  1. A

    False

  2. B

    "hello"

  3. C

    0

  4. D

    ""

  5. E

    [1]

07
True or false
1 point

Python's and and or operators always return either True or False, never an operand such as a string.

  1. A

    True

  2. B

    False

08
Written response
1 point

What numeric value does the Python expression 2 ** 3 ** 2 produce? Enter the numeric value only. No tolerance is allowed.

09
Fill in the blank
1 point

In number != 0 and 100 / number > 2, the division is skipped when number is zero because of .

10
Choose one
1 point

Which expression is equivalent to the Python chained comparison 10 <= score <= 20?

  1. A

    10 <= score and score <= 20

  2. B

    10 <= (score <= 20)

  3. C

    10 < score < 20 only

  4. D

    score <= 10 or score >= 20

11
Choose all
1 point

Which three expressions are valid examples of the string operations described in the material? Select all correct choices.

  1. A

    "a" + "b"

  2. B

    "a" + 3

  3. C

    f"Score: {95}"

  4. D

    "a" * "b"

  5. E

    "cat" in "concatenate"

12
Open ended
1 point

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.

13
Choose one
1 point

Which statement about the Python string comparison "A" < "a" is correct?

  1. A

    "apple" < "banana" is false

  2. B

    "A" < "a" is true

  3. C

    "apple" < "banana" raises an error

  4. D

    String comparisons ignore letter case

14
Choose one
1 point

In Python, what is the result of evaluating bool([])?

  1. A

    True

  2. B

    False

  3. C

    None

  4. D

    It raises a TypeError

15
Choose one
1 point

Given name = "Ada" and score = 95, what string does f"{name} scored {score}%" produce?

  1. A

    Ada scored {score}%

  2. B

    name scored 95%

  3. C

    Ada scored 95%

  4. D

    Ada scored score%

16
Choose one
1 point

What is the result of this Python code?

score = 15

10 <= score <= 20

  1. A

    True

  2. B

    False

  3. C

    15

  4. D

    A syntax error

17
Choose one
1 point

What happens when number = 0 and Python evaluates number != 0 and 100 / number > 2?

  1. A

    True

  2. B

    A division-by-zero error

  3. C

    False

  4. D

    0

18
True or false
1 point

True or false: In Python, 2 ** 3 ** 2 evaluates to 512.

  1. A

    True

  2. B

    False

19
Written response
1 point

What numeric value does the Python expression 20 / 5 * 2 produce?

20
Written response
1 point

In Python, what numeric value does the expression 29 // 6 produce?