Free Practice Quiz Question List

2 Variables and Data Types Online Quiz Questions

Use this free practice quiz with 20 questions to review 2 Variables and Data Types, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

True or false: In Python, a variable name can refer first to an integer and later to a string without declaring a new variable type.

  1. A

    True

  2. B

    False

02
Choose one
1 point

Which proposed Python name is valid and can be used as an ordinary identifier?

  1. A

    2nd_place

  2. B

    place_2

  3. C

    place-two

  4. D

    class

03
Written response
1 point

What Python type does the expression 17 / 2 produce?

04
Choose one
1 point

What is the value of 17 // 5 in Python?

  1. A

    2

  2. B

    3

  3. C

    3.4

  4. D

    4

05
True or false
1 point

True or false: In Python, int(-7.9) returns -8 because the value is rounded to the nearest integer.

  1. A

    True

  2. B

    False

06
Written response
1 point

What integer does len("Python") return?

07
Choose all
1 point

Select all operations that are supported for Python strings.

  1. A

    "Py" + "thon"

  2. B

    "ha" * 3

  3. C

    word[0] = "p"

  4. D

    word[1:4]

08
Choose all
1 point

Select all values that Python treats as false in a Boolean context.

  1. A

    False

  2. B

    None

  3. C

    "0"

  4. D

    0

  5. E

    ""

09
Choose one
1 point

Given the Python statements width = 8, height = 5, and area = width * height, what value does area refer to?

  1. A

    40

  2. B

    13

  3. C

    35

  4. D

    85

10
True or false
1 point

True or false: In Python, int(7.9) evaluates to 7.

  1. A

    True

  2. B

    False

11
Choose one
1 point

Which expression correctly reads an age from the user and converts it to an integer so that next_year = age + 1 can be calculated?

  1. A

    int(input("Enter your age: "))

  2. B

    float(input("Enter your age: "))

  3. C

    str(input("Enter your age: "))

  4. D

    bool(input("Enter your age: "))

12
Written response
1 point

What integer value does the Python expression 17 // 2 produce?

13
Choose one
1 point

Which of the following can be used as an ordinary Python variable name?

  1. A

    student_name

  2. B

    2students

  3. C

    class

  4. D

    total-cost

14
Written response
1 point

Which single Python operator produces the remainder after integer division?

15
Choose one
1 point

What value does result refer to after this code runs?

result = "" or "guest"

  1. A

    ""

  2. B

    "guest"

  3. C

    False

  4. D

    None

16
Choose one
1 point

What string does word[1:4] produce when word = "Python"?

  1. A

    "Pyt"

  2. B

    "yth"

  3. C

    "thon"

  4. D

    "Python"

17
Choose one
1 point

Which expression evaluates as false when used in a Python Boolean context?

  1. A

    0

  2. B

    1

  3. C

    " "

  4. D

    "Python"

18
Fill in the blank
1 point

Complete both blanks: A programmer wants to exchange the values of x and y without a temporary variable. The statements x, y = y, x work because Python evaluates the right-hand side before assigning the new values. A sequential approach such as x = y; y = x fails because . The comma-separated assignment used to exchange the values is called .

19
Fill in the blank
1 point

Complete both blanks: Given count = 3, the augmented assignment that increases count by one is . After that statement executes, the value of count is .

20
Open ended
1 point

Explain the difference between score = 100 and score == 100 in Python. Include what each expression does and what kind of result the comparison produces.