In Python, what value is assigned to result by this statement?
result = 2 + 3 * 4
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.
In Python, what value is assigned to result by this statement?
result = 2 + 3 * 4
20
14
24
9
Which value is produced by this Python expression?
(2 + 3) * 4
14
9
20
24
After these Python statements execute, what is the value of count?
count = 10
count = count + 1
11
10
1
9
What does the expression score == 90 do after score = 90 has already executed?
It assigns True to score.
It changes score to 89.
It produces a syntax error because comparisons cannot use numbers.
It evaluates whether score is equal to 90.
What are the data types of "42" and 42, respectively?
Both values are integers.
The first is a Boolean and the second is a string.
The first is a string and the second is an integer.
Both values are floating-point numbers.
Which statement correctly reads a whole-number quantity from the user so that the quantity can be used in integer arithmetic?
quantity = bool(input("How many? "))
quantity = int(input("How many? "))
quantity = str(input("How many? "))
quantity = float(input("How many? "))
A program uses hours = minutes // 60. If minutes is 210, what value is assigned to hours?
3
3.5
1
4
Using the following logic, what output values result when minutes = 137?
hours = minutes // 60
remaining_minutes = minutes % 60
1 hour(s) and 77 minute(s)
2 hour(s) and 60 minute(s)
3 hour(s) and 17 minute(s)
2 hour(s) and 17 minute(s)
Which statement best calculates the total cost for an item and quantity while following the material's naming guidance?
total_cost = item_price + quantity
x = item_price * quantity
total_cost = item_price * quantity
item_price = total_cost * quantity
What does the name TAX_RATE communicate in a Python program?
It is automatically protected from every reassignment by Python.
It is a function that calculates tax.
It is a string because names with underscores are text.
It is a conventionally named constant whose value is intended not to change.
What value is assigned to can_receive_discount?
is_member = True
has_coupon = False
can_receive_discount = is_member or has_coupon
True
False
None
The expression causes a type-conversion error.
What happens when a Python program attempts to evaluate "Age: " + age after age = 20?
It always converts the integer to a string automatically.
It performs numeric addition and returns a number.
It repeats the string 20 times.
It causes a type error because the operands have incompatible types.
Which description defines a literal in a program?
A name associated with a value
A value written directly in source code
A data type that represents whole numbers
A comparison that produces True or False
Which Python identifier is a valid descriptive variable name for the total price of several items?
total cost
2nd_total
total_cost
class
In Python, what data type does the literal "2026" represent?
An integer
A floating-point number
A Boolean
A string
What value is assigned to is_adult after this code runs?
age = 20
is_adult = age >= 18
True
False
20
18
What value does this Python expression produce?
2 + 3 * 4
20
24
14
11
What does the statement count = 12 do in Python?
It tests whether count already equals 12.
It stores 12 in count.
It increases count by 12.
It converts count to a string.
A program divides 17 items into groups of 5. Which result correctly describes 17 // 5 and 17 % 5?
2 complete groups and 3 remaining
3 complete groups and 0 remaining
4 complete groups and 2 remaining
3 complete groups and 2 remaining
Which statement correctly reads a whole-number quantity from the user so it can be used in arithmetic?
quantity = int(input("How many items? "))
quantity = input("How many items? ")
quantity = str(input("How many items? "))
quantity = bool(input("How many items? "))
Which sequence follows the recommended input-processing-output pattern for a program that calculates a total from user-entered values?
Display output, read input, convert input, then compute
Compute a result, read input, display output, then convert input
Read input, convert it, compute a result, then display or store it
Convert output, display input, read a result, then compute
Why would a Python programmer write TAX_RATE = 0.07 using an uppercase name?
Python automatically prevents reassignment of every uppercase name.
Uppercase naming communicates the intention that the value should remain stable.
A constant must always be stored as a string.
Constants can only represent conversion factors.
Which statement correctly creates the text Age: 20 when age contains the integer 20?
message = "Age: " + age
message = age + ": Age"
message = "Age: " * age
message = f"Age: {age}"
Using the minutes-to-hours procedure from the material, what should the program display for an input of 125 minutes?
2 hours and 5 minutes
2 hours and 60 minutes
1 hour and 65 minutes
3 hours and 5 minutes
What happens when a Python program evaluates int("hello")?
It returns the Boolean value False.
It returns the string hello as an integer.
It causes an error because the text is not a valid integer representation.
It rounds the text to the nearest whole number.
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?
quantity = input("How many?")
quantity = int(input("How many?"))
quantity = str(input("How many?"))
quantity = bool(input("How many?"))
What value does the Python expression 2 + 3 * 4 produce?
20
24
14
9
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?
2 hours and 5 minutes
2 hours and 0 minutes
3 hours and 5 minutes
125 hours and 0 minutes
After Python executes count = 10 followed by count = count + 1, what is the resulting value of count?
count remains 10 because variables cannot be updated
The code tests whether count equals 11
The code causes an error because the same variable appears on both sides
count becomes 11
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?
tax
TAX_RATE
tax rate
TaxRateValueThatChangesEveryTransaction