Answers | New Update 2026/2027 | Python
Programming Study Guide
Complete Q&A with Rationales for CIT 332
Exam Success
SECTION A: LISTS – CREATION, INDEXING, & SLICING
(Questions 1-25)
Question 1
Which of the following refer to the last element in a list
named names? (Select all that apply)
A) names[-1]
B) names[len(names) - 1]
C) names[0]
D) names[-0]
Answer: A, B
,Rationale: In Python, negative indexing starts from the end of
the list, with -1 representing the last element . The
expression len(names) - 1 gives the index of the last element
because indexing starts at 0. For a list with 5
elements, len(names) returns 5, and 5 - 1 = 4, which is the last
index .
Question 2
Given the following code:
python
nums = [3, 7, 2, 1]
print(len(nums))
print(nums[-1])
print(nums[len(nums)])
What is the output?
A) 4, 1, IndexError
B) 4, 1, 1
C) 3, 1, IndexError
D) 4, 2, IndexError
,Answer: A) 4, 1, IndexError
Rationale: len(nums) returns 4. nums[-1] accesses the last element
(1). nums[len(nums)] attempts to access nums[4], which is out of
bounds because valid indices are 0-3. This results in
an IndexError .
Question 3
What is the output of the following code?
python
list1 = [2, 3, 21, 14, 25]
print(list1[-1])
A) 2
B) 14
C) 21
D) 25
Answer: D) 25
Rationale: -1 indexing in Python selects the last element of the
list, which is 25 .
, Question 4
What is printed by the following statements?
python
alist = [3, 67, "cat", [56, 57, "dog"], [], 3.14, False]
print(alist[4:])
A) [[56, 57, "dog"], [], 3.14, False]
B) [[], 3.14, False]
C) [3, 67, "cat", [56, 57, "dog"]]
D) [[56, 57, "dog"], []]
Answer: B) [[], 3.14, False]
Rationale: Slicing with [4:] selects elements from index 4 to the
end of the list. The element at index 4 is [], followed by 3.14,
and False .
Question 5
Given list1 is [1, 3, 2], what is the result of list1 * 2?
A) [1, 3, 2, 1, 3, 2]
B) [2, 6, 4]