Which function returns the length of a Python list?
len()
size()
count()
length()
正解と解説を見る
正解: len()
len() is Python's built-in function for returning the number of items in a container. size() is used in NumPy, count() counts occurrences of a specific element, and length() does not exist in Python. The stem asks: Which function returns the length of a Python list?. The keyed answer is 1. Options: len(); size(); count(); length(). Keep this in the python bucket, and reject the neighbor term that solves a different job.
問 2
Which keyword is used for exception handling in Python?
catch
except
rescue
error
正解と解説を見る
正解: except
Python uses try/except blocks for exception handling. 'catch' is used in Java and C++, 'rescue' is Ruby's keyword, and 'error' is not an exception-handling keyword in any major language. The stem asks: Which keyword is used for exception handling in Python?. The keyed answer is 2. Options: catch; except; rescue; error. Keep this in the python bucket, and reject the neighbor term that solves a different job.
問 3
True/False: A Python tuple is mutable.
正解と解説を見る
正解: false
Tuples are immutable sequences in Python. Once created, their elements cannot be changed, added, or removed. This immutability makes tuples hashable and usable as dictionary keys, unlike lists. The stem asks: True/False: A Python tuple is mutable.. The keyed answer is false. Keep this in the python bucket, and reject the neighbor term that solves a different job.
問 4
Which Big-O notation is the fastest?
O(1)
O(n)
O(n log n)
O(n^2)
正解と解説を見る
正解: O(1)
O(1) represents constant time complexity — the operation takes the same time regardless of input size. Examples include hash table lookup and array index access. O(n) is linear, O(n log n) is typical for efficient sorting, and O(n^2) is quadratic.
問 5
Which data is suitable for one-hot encoding?
Ordinal category
Nominal category
Continuous value
Image
正解と解説を見る
正解: Nominal category
One-hot encoding creates binary columns for each category and is ideal for nominal (unordered) categories like color or country. Ordinal categories have inherent order and are better served by label encoding. Continuous values and images require different representations.
問 6
Why is MinMaxScaler weak to outliers?
Sensitive to outliers
Slow
Ignores categories
Requires labels
正解と解説を見る
正解: Sensitive to outliers
MinMaxScaler normalizes features to a fixed range (typically 0-1) using min and max values. A single extreme outlier shifts the min or max dramatically, compressing all other values into a narrow band. StandardScaler or RobustScaler are more resilient alternatives.
問 7
Which advantage do Transformers have over RNNs?
Recursion
Parallelization
Lower memory use
Simplicity
正解と解説を見る
正解: Parallelization
Transformers process all positions simultaneously via self-attention, enabling massive parallelization during training. RNNs must process sequences step-by-step, creating a sequential bottleneck. This parallelism allows Transformers to train on much larger datasets efficiently.
問 8
True/False: Embeddings are used for similarity calculation.
正解と解説を見る
正解: true
Embeddings map discrete items (words, sentences, images) into dense continuous vector spaces where geometric distance reflects semantic similarity. Cosine similarity or Euclidean distance between embedding vectors is widely used for search, recommendation, and clustering tasks.
問 9
What issue occurs when top-k=1 in RAG retrieval?
Missing relevant chunks
Slow inference
Encoding failure
Overfitting
正解と解説を見る
正解: Missing relevant chunks
Setting top-k=1 retrieves only the single most similar chunk, which risks missing other relevant passages needed to answer the query completely. Increasing k improves recall at the cost of including some irrelevant context. A typical production setting uses k=3 to k=10.
問 10
Name one method to speed up LLM inference.
正解と解説を見る
正解: quantization
Quantization reduces model weights from higher precision (e.g. float32) to lower precision (e.g. int8 or int4), significantly reducing memory footprint and computation time. Other techniques include KV-cache optimization, speculative decoding, and model distillation.
問 11
What Python keyword opens a file safely?
file()
open()
with open()
new()
正解と解説を見る
正解: with open()
The 'with' statement combined with open() creates a context manager that automatically closes the file when the block exits, even if an exception occurs. Using open() alone requires manual close() calls, risking resource leaks.
問 12
True/False: Python lists can hold mixed data types.
正解と解説を見る
正解: true
Python lists are heterogeneous containers that can store objects of any type simultaneously, e.g. [1, 'hello', 3.14, None]. This flexibility comes from Python's dynamic typing — each list element is a reference to an object on the heap.
問 13
Which operation is fastest for hash maps?
Insert
Delete
Lookup
All of the above
正解と解説を見る
正解: All of the above
Hash maps (dictionaries in Python) provide average O(1) time complexity for insert, delete, and lookup operations by computing a hash of the key to directly index into a bucket array. Worst case is O(n) due to hash collisions, but this is rare with good hash functions.
問 14
What is the purpose of normalization?
Unify scale
Remove missing values
Encode categories
Remove outliers
正解と解説を見る
正解: Unify scale
Normalization rescales features to a common range (e.g. 0-1 for MinMaxScaler or zero mean and unit variance for StandardScaler). This prevents features with larger magnitudes from dominating distance-based algorithms like k-NN and gradient-based optimizers in neural networks.
問 15
Which model is sensitive to the curse of dimensionality?
Logistic regression
k-NN
Naive Bayes
Decision tree
正解と解説を見る
正解: k-NN
k-Nearest Neighbors relies on distance metrics to find similar data points. In high-dimensional spaces, distances between all points converge, making the notion of 'nearest' meaningless. This phenomenon is called the curse of dimensionality. Dimensionality reduction (e.g. PCA) is a common mitigation.
問 16
What is the goal of K-means?
Classification
Regression
Clustering
Dimensionality reduction
正解と解説を見る
正解: Clustering
K-means is an unsupervised clustering algorithm that partitions data into k groups by iteratively assigning points to the nearest centroid and updating centroids. It minimizes within-cluster sum of squared distances. It requires specifying k in advance and assumes roughly spherical clusters.
問 17
True/False: PCA is a dimensionality reduction method.
正解と解説を見る
正解: true
Principal Component Analysis (PCA) projects high-dimensional data onto a lower-dimensional subspace defined by the directions of maximum variance (principal components). It preserves as much information as possible while reducing feature count, helping with visualization, noise reduction, and computational efficiency.
問 18
What direction does PCA prioritize?
Largest variance
Smallest variance
Lowest mean
Random
正解と解説を見る
正解: Largest variance
PCA finds orthogonal axes (principal components) that capture the maximum variance in the data. The first component explains the most variance, the second the next most while being orthogonal to the first, and so on. Directions with minimal variance are discarded as noise.
問 19
What activation helps reduce vanishing gradients?
Sigmoid
Tanh
ReLU
Linear
正解と解説を見る
正解: ReLU
ReLU (Rectified Linear Unit) outputs max(0, x), providing a constant gradient of 1 for positive inputs. Sigmoid and tanh saturate at extreme values, producing near-zero gradients that vanish through deep layers during backpropagation. ReLU largely solved this problem, enabling training of much deeper networks.
問 20
Which optimizer adaptively adjusts learning rates?
SGD
Adam
RMSProp
GD
正解と解説を見る
正解: Adam
Adam (Adaptive Moment Estimation) maintains per-parameter learning rates by combining momentum (first moment) and RMSProp (second moment) of gradients. This adaptive behavior helps navigate different curvatures in the loss landscape, typically converging faster than vanilla SGD.