Free Practice Quiz Question List

2 Variables, Data Types, and Expressions Online Quiz Questions

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

30 questions
01
Choose one
1 point

In Python, what value is assigned to result by this statement?

result = 2 + 3 * 4

  1. A

    20

  2. B

    14

  3. C

    24

  4. D

    9

02
Choose one
1 point

Which value is produced by this Python expression?

(2 + 3) * 4

  1. A

    14

  2. B

    9

  3. C

    20

  4. D

    24

03
Choose one
1 point

After these Python statements execute, what is the value of count?

count = 10

count = count + 1

  1. A

    11

  2. B

    10

  3. C

    1

  4. D

    9

04
Choose one
1 point

What does the expression score == 90 do after score = 90 has already executed?

  1. A

    It assigns True to score.

  2. B

    It changes score to 89.

  3. C

    It produces a syntax error because comparisons cannot use numbers.

  4. D

    It evaluates whether score is equal to 90.

05
Choose one
1 point

What are the data types of "42" and 42, respectively?

  1. A

    Both values are integers.

  2. B

    The first is a Boolean and the second is a string.

  3. C

    The first is a string and the second is an integer.

  4. D

    Both values are floating-point numbers.

06
Choose one
1 point

Which statement correctly reads a whole-number quantity from the user so that the quantity can be used in integer arithmetic?

  1. A

    quantity = bool(input("How many? "))

  2. B

    quantity = int(input("How many? "))

  3. C

    quantity = str(input("How many? "))

  4. D

    quantity = float(input("How many? "))

07
Choose one
1 point

A program uses hours = minutes // 60. If minutes is 210, what value is assigned to hours?

  1. A

    3

  2. B

    3.5

  3. C

    1

  4. D

    4

08
Choose one
1 point

Using the following logic, what output values result when minutes = 137?

hours = minutes // 60

remaining_minutes = minutes % 60

  1. A

    1 hour(s) and 77 minute(s)

  2. B

    2 hour(s) and 60 minute(s)

  3. C

    3 hour(s) and 17 minute(s)

  4. D

    2 hour(s) and 17 minute(s)

09
Choose one
1 point

Which statement best calculates the total cost for an item and quantity while following the material's naming guidance?

  1. A

    total_cost = item_price + quantity

  2. B

    x = item_price * quantity

  3. C

    total_cost = item_price * quantity

  4. D

    item_price = total_cost * quantity

10
Choose one
1 point

What does the name TAX_RATE communicate in a Python program?

  1. A

    It is automatically protected from every reassignment by Python.

  2. B

    It is a function that calculates tax.

  3. C

    It is a string because names with underscores are text.

  4. D

    It is a conventionally named constant whose value is intended not to change.

11
Choose one
1 point

What value is assigned to can_receive_discount?

is_member = True

has_coupon = False

can_receive_discount = is_member or has_coupon

  1. A

    True

  2. B

    False

  3. C

    None

  4. D

    The expression causes a type-conversion error.

12
Choose one
1 point

What happens when a Python program attempts to evaluate "Age: " + age after age = 20?

  1. A

    It always converts the integer to a string automatically.

  2. B

    It performs numeric addition and returns a number.

  3. C

    It repeats the string 20 times.

  4. D

    It causes a type error because the operands have incompatible types.

13
Choose one
1 point

Which description defines a literal in a program?

  1. A

    A name associated with a value

  2. B

    A value written directly in source code

  3. C

    A data type that represents whole numbers

  4. D

    A comparison that produces True or False

14
Choose one
1 point

Which Python identifier is a valid descriptive variable name for the total price of several items?

  1. A

    total cost

  2. B

    2nd_total

  3. C

    total_cost

  4. D

    class

15
Choose one
1 point

In Python, what data type does the literal "2026" represent?

  1. A

    An integer

  2. B

    A floating-point number

  3. C

    A Boolean

  4. D

    A string

16
Choose one
1 point

What value is assigned to is_adult after this code runs?

age = 20
is_adult = age >= 18

  1. A

    True

  2. B

    False

  3. C

    20

  4. D

    18

17
Choose one
1 point

What value does this Python expression produce?

2 + 3 * 4

  1. A

    20

  2. B

    24

  3. C

    14

  4. D

    11

18
Choose one
1 point

What does the statement count = 12 do in Python?

  1. A

    It tests whether count already equals 12.

  2. B

    It stores 12 in count.

  3. C

    It increases count by 12.

  4. D

    It converts count to a string.

19
Choose one
1 point

A program divides 17 items into groups of 5. Which result correctly describes 17 // 5 and 17 % 5?

  1. A

    2 complete groups and 3 remaining

  2. B

    3 complete groups and 0 remaining

  3. C

    4 complete groups and 2 remaining

  4. D

    3 complete groups and 2 remaining

20
Choose one
1 point

Which statement correctly reads a whole-number quantity from the user so it can be used in arithmetic?

  1. A

    quantity = int(input("How many items? "))

  2. B

    quantity = input("How many items? ")

  3. C

    quantity = str(input("How many items? "))

  4. D

    quantity = bool(input("How many items? "))

21
Choose one
1 point

Which sequence follows the recommended input-processing-output pattern for a program that calculates a total from user-entered values?

  1. A

    Display output, read input, convert input, then compute

  2. B

    Compute a result, read input, display output, then convert input

  3. C

    Read input, convert it, compute a result, then display or store it

  4. D

    Convert output, display input, read a result, then compute

22
Choose one
1 point

Why would a Python programmer write TAX_RATE = 0.07 using an uppercase name?

  1. A

    Python automatically prevents reassignment of every uppercase name.

  2. B

    Uppercase naming communicates the intention that the value should remain stable.

  3. C

    A constant must always be stored as a string.

  4. D

    Constants can only represent conversion factors.

23
Choose one
1 point

Which statement correctly creates the text Age: 20 when age contains the integer 20?

  1. A

    message = "Age: " + age

  2. B

    message = age + ": Age"

  3. C

    message = "Age: " * age

  4. D

    message = f"Age: {age}"

24
Choose one
1 point

Using the minutes-to-hours procedure from the material, what should the program display for an input of 125 minutes?

  1. A

    2 hours and 5 minutes

  2. B

    2 hours and 60 minutes

  3. C

    1 hour and 65 minutes

  4. D

    3 hours and 5 minutes

25
Choose one
1 point

What happens when a Python program evaluates int("hello")?

  1. A

    It returns the Boolean value False.

  2. B

    It returns the string hello as an integer.

  3. C

    It causes an error because the text is not a valid integer representation.

  4. D

    It rounds the text to the nearest whole number.

26
Choose one
1 point

A Python program asks the user for the number of items and then multiplies that value by a price. Which statement stores the user’s response in the most appropriate type for the multiplication?

  1. A

    quantity = input("How many?")

  2. B

    quantity = int(input("How many?"))

  3. C

    quantity = str(input("How many?"))

  4. D

    quantity = bool(input("How many?"))

27
Choose one
1 point

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

  1. A

    20

  2. B

    24

  3. C

    14

  4. D

    9

28
Choose one
1 point

Using Python’s // and % operators, what should a program report for an input of 125 minutes when converting the time into complete hours and remaining minutes?

  1. A

    2 hours and 5 minutes

  2. B

    2 hours and 0 minutes

  3. C

    3 hours and 5 minutes

  4. D

    125 hours and 0 minutes

29
Choose one
1 point

After Python executes count = 10 followed by count = count + 1, what is the resulting value of count?

  1. A

    count remains 10 because variables cannot be updated

  2. B

    The code tests whether count equals 11

  3. C

    The code causes an error because the same variable appears on both sides

  4. D

    count becomes 11

30
Choose one
1 point

A program needs a named value representing a tax rate that is intended to remain stable. Which name best follows the Python convention for a constant?

  1. A

    tax

  2. B

    TAX_RATE

  3. C

    tax rate

  4. D

    TaxRateValueThatChangesEveryTransaction