100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 200
A learner is checking strided list slices. Which final result follows from this separate test?a=[3,6,9,12,15,18]
print(a[-2::-2])
- Prints '[9, 3]'
- Prints '[3, 9, 15]'
- Prints '[15, 9]'
- Prints '[15, 9, 3]'
Explanation
Correct Answer
D:The snippet prints '[15, 9, 3]'. The optional third slice component controls stride, including reverse traversal with a negative step.
Incorrect Answers
A:This predicts that the snippet prints '[9, 3]', but executing the displayed Python 3 code prints '[15, 9, 3]'. The optional third slice component controls stride, including reverse traversal with a negative step.
B:This predicts that the snippet prints '[3, 9, 15]', but executing the displayed Python 3 code prints '[15, 9, 3]'. The optional third slice component controls stride, including reverse traversal with a negative step.
C:This predicts that the snippet prints '[15, 9]', but executing the displayed Python 3 code prints '[15, 9, 3]'. The optional third slice component controls stride, including reverse traversal with a negative step.
Question 201
A learner is checking append versus extend. What is the exact printed result or uncaught exception?a=[1]
a.append([2,3])
print(a)
- Prints '[[2, 3], 1]'
- Prints '[[2, 3]]'
- Prints '[1]'
- Prints '[1, [2, 3]]'
Explanation
Correct Answer
D:The snippet prints '[1, [2, 3]]'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Incorrect Answers
A:This predicts that the snippet prints '[[2, 3], 1]', but executing the displayed Python 3 code prints '[1, [2, 3]]'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
B:This predicts that the snippet prints '[[2, 3]]', but executing the displayed Python 3 code prints '[1, [2, 3]]'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
C:This predicts that the snippet prints '[1]', but executing the displayed Python 3 code prints '[1, [2, 3]]'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Question 202
A developer tests append versus extend. The following code prints '[1, 2, 3]'. Which explanation best accounts for that observed behavior?a=[1]
a.extend([2,3])
print(a)
- pop removes and returns an indexed element, using the last position when no index is supplied.
- Membership searches list elements by equality; .index returns the first matching position or raises ValueError.
- append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
- When a dictionary literal repeats the same key, the later value replaces the earlier value.
Explanation
Correct Answer
C:This is the operative language rule for the code. It directly explains why the example prints '[1, 2, 3]'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The pop returns and removes by index topic does not explain why the code prints '[1, 2, 3]'. The relevant Python rule is: append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
B:The list membership and index topic does not explain why the code prints '[1, 2, 3]'. The relevant Python rule is: append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
D:The duplicate dictionary keys overwritten topic does not explain why the code prints '[1, 2, 3]'. The relevant Python rule is: append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Question 203
A learner is checking append versus extend. After this modification, what does Python 3 actually do?a=[]
a.extend("hi")
print(a)
- Prints "['i']"
- Prints "['h']"
- Prints "['i', 'h']"
- Prints "['h', 'i']"
Explanation
Correct Answer
D:The snippet prints "['h', 'i']". append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Incorrect Answers
A:This predicts that the snippet prints "['i']", but executing the displayed Python 3 code prints "['h', 'i']". append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
B:This predicts that the snippet prints "['h']", but executing the displayed Python 3 code prints "['h', 'i']". append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
C:This predicts that the snippet prints "['i', 'h']", but executing the displayed Python 3 code prints "['h', 'i']". append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Question 204
A learner is checking append versus extend. Which final result follows from this separate test?a=[4]
a.append((5,6))
print(len(a))
- Prints '3'
- Prints '2'
- Prints '4'
- Prints '1'
Explanation
Correct Answer
B:The snippet prints '2'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Incorrect Answers
A:This predicts that the snippet prints '3', but executing the displayed Python 3 code prints '2'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
C:This predicts that the snippet prints '4', but executing the displayed Python 3 code prints '2'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
D:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints '2'. append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
Question 205
A learner is checking insert location and shifting. What is the exact printed result or uncaught exception?a=[1,3]
a.insert(1,2)
print(a)
- Prints '[3, 2, 1]'
- Prints '[1, 2, 3]'
- Prints '[2, 3]'
- Prints '[1, 2]'
Explanation
Correct Answer
B:The snippet prints '[1, 2, 3]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Incorrect Answers
A:This predicts that the snippet prints '[3, 2, 1]', but executing the displayed Python 3 code prints '[1, 2, 3]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
C:This predicts that the snippet prints '[2, 3]', but executing the displayed Python 3 code prints '[1, 2, 3]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
D:This predicts that the snippet prints '[1, 2]', but executing the displayed Python 3 code prints '[1, 2, 3]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Question 206
A developer tests insert location and shifting. The following code prints "['z', 'a', 'c']". Which explanation best accounts for that observed behavior?a=["a","c"]
a.insert(0,"z")
print(a)
- list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
- append adds its argument as one element, whereas extend iterates over its argument and adds its elements.
- split converts a string to parts using a delimiter; join combines string parts with a separator.
- del removes a list element or slice and shifts surviving elements; it does not produce a return value.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints "['z', 'a', 'c']"; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The append versus extend topic does not explain why the code prints "['z', 'a', 'c']". The relevant Python rule is: list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
C:The split and join strings topic does not explain why the code prints "['z', 'a', 'c']". The relevant Python rule is: list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
D:The del and list slice deletion topic does not explain why the code prints "['z', 'a', 'c']". The relevant Python rule is: list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Question 207
A learner is checking insert location and shifting. After this modification, what does Python 3 actually do?a=[1,2]
a.insert(100,9)
print(a)
- Prints '[2, 9]'
- Prints '[9, 2, 1]'
- Prints '[1, 2]'
- Prints '[1, 2, 9]'
Explanation
Correct Answer
D:The snippet prints '[1, 2, 9]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Incorrect Answers
A:This predicts that the snippet prints '[2, 9]', but executing the displayed Python 3 code prints '[1, 2, 9]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
B:This predicts that the snippet prints '[9, 2, 1]', but executing the displayed Python 3 code prints '[1, 2, 9]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
C:This predicts that the snippet prints '[1, 2]', but executing the displayed Python 3 code prints '[1, 2, 9]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Question 208
A learner is checking insert location and shifting. Which final result follows from this separate test?a=[2,4]
a.insert(-1,3)
print(a)
- Prints '[3, 4]'
- Prints '[2, 3]'
- Prints '[4, 3, 2]'
- Prints '[2, 3, 4]'
Explanation
Correct Answer
D:The snippet prints '[2, 3, 4]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Incorrect Answers
A:This predicts that the snippet prints '[3, 4]', but executing the displayed Python 3 code prints '[2, 3, 4]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
B:This predicts that the snippet prints '[2, 3]', but executing the displayed Python 3 code prints '[2, 3, 4]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
C:This predicts that the snippet prints '[4, 3, 2]', but executing the displayed Python 3 code prints '[2, 3, 4]'. list.insert(i, x) inserts x before position i and shifts later elements rather than replacing them.
Question 209
A learner is checking pop returns and removes by index. What is the exact printed result or uncaught exception?a=[7,8,9]
x=a.pop()
print(x,a)
- Prints ']8 ,7[ 9'
- Prints '9 [7, 8]?'
- Prints '9 [7, 8]'
- Prints '9 [7, 8'
Explanation
Correct Answer
C:The snippet prints '9 [7, 8]'. pop removes and returns an indexed element, using the last position when no index is supplied.
Incorrect Answers
A:This predicts that the snippet prints ']8 ,7[ 9', but executing the displayed Python 3 code prints '9 [7, 8]'. pop removes and returns an indexed element, using the last position when no index is supplied.
B:This predicts that the snippet prints '9 [7, 8]?', but executing the displayed Python 3 code prints '9 [7, 8]'. pop removes and returns an indexed element, using the last position when no index is supplied.
D:This predicts that the snippet prints '9 [7, 8', but executing the displayed Python 3 code prints '9 [7, 8]'. pop removes and returns an indexed element, using the last position when no index is supplied.
Question 210
A developer tests pop returns and removes by index. The following code prints '2 [4, 6]'. Which explanation best accounts for that observed behavior?a=[2,4,6]
x=a.pop(0)
print(x,a)
- pop removes and returns an indexed element, using the last position when no index is supplied.
- String indexing and slicing resemble list indexing, but slicing returns a new string and excludes the stop.
- List slicing returns elements from start up to but not including stop; omitted bounds use list ends.
- Accessing a nested list uses successive indexes: first select the row, then its element.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '2 [4, 6]'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The string negative indexing and slices topic does not explain why the code prints '2 [4, 6]'. The relevant Python rule is: pop removes and returns an indexed element, using the last position when no index is supplied.
C:The list slicing excludes stop topic does not explain why the code prints '2 [4, 6]'. The relevant Python rule is: pop removes and returns an indexed element, using the last position when no index is supplied.
D:The nested list matrix indexing topic does not explain why the code prints '2 [4, 6]'. The relevant Python rule is: pop removes and returns an indexed element, using the last position when no index is supplied.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests