in Python OA Actual Exam 2026/2027 |
Questions with Verified Answers | 100%
Correct | Pass Guaranteed
Q001: What will the following code output?
x=7
y=3
print(x % y)
A. 2.333
B. 2
C. 1
D. 0
ANSWER: C
Verified Solution: The modulo operator % returns the
remainder of 7 divided by 3, which is 1.
Q002: Which data type is produced by the expression: 3 +
4.0?
A. int
P a g e 1 | 32
,B. float
C. str
D. complex
ANSWER: B
Verified Solution: Python promotes the int 3 to float 3.0
and returns 7.0, a float.
Q003: After running:
s = "hello"
s = s.upper()
print(s)
what is displayed?
A. hello
B. HELLO
C. Hello
D. Error
ANSWER: B
Verified Solution: The upper() method returns an all-caps
version of the string.
Q004: What is the value of lst after:
lst = [1, 2, 3]
lst.append(4)
lst.insert(1, 5)
A. [1, 5, 2, 3, 4]
P a g e 2 | 32
,B. [5, 1, 2, 3, 4]
C. [1, 2, 3, 4, 5]
D. [1, 2, 5, 3, 4]
ANSWER: A
Verified Solution: append adds 4 to the end, then insert
places 5 at index 1, shifting the rest right.
Q005: Which loop prints exactly the numbers 0 1 2 3 4?
A. for i in range(1,5): print(i)
B. for i in range(5): print(i)
C. for i in range(0,6): print(i)
D. for i in range(4): print(i)
ANSWER: B
Verified Solution: range(5) yields 0 through 4 inclusive.
Q006: What does the function call foo(4) return if foo is
defined as:
def foo(n):
return n * 2 if n > 0 else 0
A. 0
B. 4
C. 8
D. 16
ANSWER: C
Verified Solution: 4 > 0 so 4 * 2 = 8 is returned.
P a g e 3 | 32
, Q007: Which of the following correctly creates a tuple
with a single element, the integer 5?
A. (5)
B. [5]
C. (5,)
D. {5}
ANSWER: C
Verified Solution: A trailing comma is required to form a
single-element tuple: (5,).
Q008: What is the output of:
print("Python"[1:4])
A. Pyt
B. yth
C. tho
D. ython
ANSWER: B
Verified Solution: Slicing extracts indices 1, 2, 3 yielding
'yth'.
Q009: Given d = {'a': 1, 'b': 2}, what is the result of
d.get('c', 3)?
A. KeyError
B. 2
C. 3
P a g e 4 | 32