ITEM PRACTICE FINAL EXAMINATION WITH EVIDENCE-BASED CODING
RATIONALES, DATA STRUCTURE EXPLANATIONS, ALGORITHM
BREAKDOWNS, AND MACHINE LEARNING CONCEPTS FOR GEORGIA TECH
MASTERS IN ANALYTICS STUDENTS – 2026/2027 CURRICULUM ALIGNED |
100% CORRECT | GUARANTEED PASS
QUESTION 1
You are given a Python list data = [3, 1, 4, 1, 5, 9, 2, 6]. Which of the following code
snippets will produce a new list containing only the unique values in the order they first
appear?
A) list(set(data))
B) sorted(set(data))
C) [x for i, x in enumerate(data) if x not in data[:i]]
D) list(dict.fromkeys(data))
E) Both C and D
Answer: E – Both C and D
Rationale: Option C uses a list comprehension with a slice to check previous
occurrences, preserving order and uniqueness. Option D uses dict.fromkeys(data) which
creates a dictionary with keys from the list, preserving insertion order, then converts to a
list. Option A loses order, Option B sorts the unique values.
Takeaway: To preserve order when deduplicating, use dict.fromkeys() or list
comprehension with membership check.
QUESTION 2
What is the output of the following code?
,python
x = [1, 2, 3]
y = x
y.append(4)
print(x)
A) [1, 2, 3]
B) [1, 2, 3, 4]
C) [4, 3, 2, 1]
D) Error
Answer: B – [1, 2, 3, 4]
Rationale: In Python, lists are mutable objects. When y = x, both variables reference the
same list object. Modifying y modifies the same list that x points to. This is a shallow
copy vs deep copy concept.
Takeaway: Assigning a list to a new variable does NOT create a new list; it creates a
reference to the same list. Use copy() or list() for a shallow copy.
QUESTION 3
Which of the following is NOT a valid Python data type?
A) int
B) float
C) complex
D) decimal
Answer: D – decimal
Rationale: int, float, complex are built-in numeric types in Python. decimal is a module,
not a built-in type (you must import decimal.Decimal). The built-in types include int,
float, complex, bool, str, list, tuple, dict, set, and frozenset.
Takeaway: decimal is a module, not a built-in data type.
,QUESTION 4
What is the output of the following code?
python
a = [1, 2, 3, 4, 5]
print(a[1:4])
A) [1, 2, 3]
B) [1, 2, 3, 4]
C) [2, 3, 4]
D) [2, 3, 4, 5]
Answer: C – [2, 3, 4]
Rationale: List slicing uses the syntax a[start:end] where start is inclusive and end is
exclusive. a[1:4] includes indices 1, 2, and 3 (values 2, 3, 4). Index 4 is excluded.
Takeaway: Slicing is inclusive of the start index and exclusive of the end index.
QUESTION 5
You are given a Python list data = [3, 1, 4, 1, 5, 9, 2, 6]. Which of the following code
snippets will produce a new list containing only the unique values in the order they first
appear?
A) list(set(data))
B) sorted(set(data))
C) [x for i, x in enumerate(data) if x not in data[:i]]
D) list(dict.fromkeys(data))
E) Both C and D
Answer: E – Both C and D
Rationale: Option C uses a list comprehension with a slice to check previous
occurrences, preserving order and uniqueness. Option D uses dict.fromkeys(data) which
creates a dictionary with keys from the list, preserving insertion order, then converts to a
list. Option A loses order, Option B sorts the unique values.
, Takeaway: To preserve order when deduplicating, use dict.fromkeys() or list
comprehension with membership check.
QUESTION 6
What is the difference between list.append() and list.extend()?
A) append() adds a single element; extend() adds multiple elements from an iterable
B) append() adds multiple elements; extend() adds a single element
C) They are the same
D) append() only works with integers
Answer: A – append() adds a single element; extend() adds multiple elements from
an iterable
Rationale: append() adds its argument as a single element to the end of the list.
extend() iterates over its argument (which must be an iterable) and adds each element
to the list. For example, [1,2].append([3,4]) gives [1,2,[3,4]] while [1,2].extend([3,4]) gives
[1,2,3,4].
Takeaway: append() adds one item; extend() adds each item from an iterable.
QUESTION 7
What is the output of the following code?
python
data = {'a': 1, 'b': 2, 'c': 3}
print(data.get('d', 0))
A) 0
B) 1
C) KeyError
D) None
Answer: A – 0