Free Practice Quiz Question List

02 Variables, Expressions, and Input/Output Online Quiz Questions

Use this free practice quiz with 20 questions to review 02 Variables, Expressions, and Input/Output, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

Consider this Python code: balance = 100; balance = balance - 25; balance = balance + 10. After all three statements execute, is balance equal to 85?

  1. A

    True

  2. B

    False

02
Choose one
1 point

Which item is an integer literal in Python?

  1. A

    answer

  2. B

    42

  3. C

    value

  4. D

    number

03
Written response
1 point

What type of value does Python's input() function return before any conversion?

04
Fill in the blank
1 point

Complete the statement: In Python, the operator that assigns a value to a variable is .

05
Choose one
1 point

What value is assigned to result by this statement: result = 2 + 3 * 4?

  1. A

    10

  2. B

    20

  3. C

    14

  4. D

    24

06
True or false
1 point

True or false: In Python, assigning a new value to an uppercase constant name always causes an error.

  1. A

    True

  2. B

    False

07
Choose all
1 point

Which operations are demonstrated by this data flow: receive a number as text, convert it to an integer, store the result, and display it? Select all four correct choices.

  1. A

    Reading a response with input()

  2. B

    Displaying text with print()

  3. C

    Converting text with int()

  4. D

    Storing a result through assignment

  5. E

    Merely writing an expression without using its result

08
Written response
1 point

What is the name of the arithmetic operation performed by the Python operator //?

09
Fill in the blank
1 point

Complete the statement: A Python string written with a leading f so that expressions can be evaluated inside braces is called an .

10
Choose one
1 point

Which expression tests whether the variable score has the value 100?

  1. A

    score = 100

  2. B

    score == 100

  3. C

    score != 100

  4. D

    score + 100

11
Choose all
1 point

Which three statements accurately describe common issues or safeguards when using Python input? Select all correct choices.

  1. A

    Two unconverted numeric inputs can be concatenated instead of added.

  2. B

    input() automatically returns an integer when the user enters digits.

  3. C

    int() can convert suitable numeric text for arithmetic.

  4. D

    Every text response can be converted successfully with int().

  5. E

    A conversion can fail when the text does not have the expected numeric format.

12
Choose one
1 point

What value does count have after this code executes? count = 5; count += 2; count *= 3.

  1. A

    15

  2. B

    17

  3. C

    21

  4. D

    7

13
Open ended
1 point

Trace this Python code and state the final values of subtotal, tax, and total, explaining how each value is produced: TAX_RATE = 0.08; price = 12; quantity = 3; subtotal = price * quantity; tax = subtotal * TAX_RATE; total = subtotal + tax.

14
Choose one
1 point

What value is assigned to remainder by this Python statement: remainder = 17 % 5?

  1. A

    3

  2. B

    12

  3. C

    2

  4. D

    5

15
True or false
1 point

True or false: The Python statement x = x + 1 is valid when x already has the value 4, and afterward x has the value 5.

  1. A

    True

  2. B

    False

16
Choose one
1 point

Which statement best describes the conventional use of uppercase names such as TAX_RATE in Python?

  1. A

    Python prevents any later assignment to an uppercase name.

  2. B

    An uppercase name communicates that the program intends the value not to change.

  3. C

    Only string values can be assigned to uppercase names.

  4. D

    An uppercase name automatically creates a special constant object.

17
Choose one
1 point

What value is assigned to result by this statement?

result = 2 + 3 * 4

  1. A

    10

  2. B

    20

  3. C

    14

  4. D

    24

18
Written response
1 point

What is the final value of balance after this code executes?

balance = 100

balance = balance - 25

balance = balance + 10

19
Choose one
1 point

Suppose score = 100. What does is_perfect = (score == 100) do?

  1. A

    It increases score by 100.

  2. B

    It tests whether score equals 100 and stores the Boolean result.

  3. C

    It changes the type of score to Boolean without testing it.

  4. D

    It tests whether score is greater than 100.

20
Written response
1 point

Which Python function converts numeric text into an integer?