PRACTICE TEST 1 2026/2027 | OA Guide | Western
Governors University | Pass Guaranteed - A+ Graded
SECTION 1: PYTHON SYNTAX, VARIABLES & DATA TYPES (Q1-12)
Q1. What is the output of the following code snippet?
PythonCopy
x = 7
y = 2
print(x // y, x % y)
A. 3.5 1
B. 3 1
C. 3.5 0
D. 4 1
B. 3 1 [CORRECT]
Rationale: The // operator performs floor division (7 // 2 = 3), and % is the modulo
operator (7 % 2 = 1). Option A confuses // with regular division (/), option C is wrong
on both counts, and option D incorrectly rounds up instead of down.
Q2. Consider the following code. What is the final value of result?
PythonCopy
a = "42"
b = 3
result = int(a) + b * 2
,A. "4232"
B. 48
C. 84
D. 45
B. 48 [CORRECT]
Rationale: int(a) converts "42" to integer 42. Following order of operations
(PEMDAS), b * 2 = 6 first, then 42 + 6 = 48. Option A incorrectly treats it as string
concatenation, option C multiplies before adding incorrectly, and option D uses 3 + 2
= 5 then 42 * 5.
Q3. Which of the following is a valid Python variable name?
A. 2nd_value
B. second-value
C. second_value
D. second value
C. second_value [CORRECT]
Rationale: Python variable names must start with a letter or underscore, contain only
letters, digits, and underscores. Option A starts with a digit, option B contains a hyphen
(treated as minus operator), and option D contains a space. second_value follows all
naming conventions.
Q4. What is the output of this code?
PythonCopy
name = "Alice"
age = 25
print(f"{name} is {age + 5} years old in 5 years")
A. Alice is 25 years old in 5 years
,B. Alice is age + 5 years old in 5 years
C. Alice is 30 years old in 5 years
D. SyntaxError: invalid syntax
C. Alice is 30 years old in 5 years [CORRECT]
Rationale: f-strings evaluate expressions inside curly braces at runtime. age + 5 =
30. Option A ignores the expression evaluation, option B treats it as literal text, and
option D is incorrect because f-strings fully support expressions inside braces.
Q5. What data type is the result of the expression in Python 3?
A. int
B. float
C. str
D. bool
B. float [CORRECT]
Rationale: In Python 3, the / operator always returns a float, even when dividing two
integers ( = 5.0). The // operator returns an int. Option A would be correct
for // but not /, and options C and D are unrelated to division.
Q6. What is the output of this code?
PythonCopy
s = "Programming"
print(s[3:8])
A. "gramm"
B. "gram"
C. "rammi"
D. "ramm"
, A. "gramm" [CORRECT]
Rationale: String slicing s[3:8] extracts characters from index 3 up to (but not
including) index 8. For "Programming": index 0='P', 1='r', 2='o', 3='g', 4='r', 5='a', 6='m',
7='m', 8='i'. So indices 3–7 give 'g','r','a','m','m' = "gramm". Option B misses
the final 'm', option C starts at the wrong index, and option D has wrong characters.
Q7. What is the value of the expression bool(0) + bool("False") + bool([])?
A. 0
B. 1
C. 2
D. 3
B. 1 [CORRECT]
Rationale: bool(0) is False (0), bool("False") is True (1) because any non-empty
string is truthy, and bool([]) is False (0) because empty lists are falsy. So 0 + 1 +
0 = 1. Option A ignores the truthy string, option C incorrectly counts [] as truthy, and
option D counts all as truthy.
Q8. Which of the following correctly converts a float to an integer in Python?
A. int(3.7) results in 4
B. int(3.7) results in 3
C. round(3.7) results in 3
D. float(3) results in 3
B. int(3.7) results in 3 [CORRECT]
Rationale: int() truncates toward zero (not rounding), so int(3.7) = 3. Option A
incorrectly states rounding behavior. Option C is wrong because round(3.7) = 4.
Option D is wrong because float(3) = 3.0, not 3.