179 questions
No questions match those filters.
For ML code, what's the real difference between a list,...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansThey differ along two axes — ordering and mutability — and each one maps onto a specific ML habit. Lists are ordered and mutable: they’re what you reach for to hold a batch of predictions or a running list of features. Tuples are ordered but locked once created, which makes them the right choice for returning several values from a function (like precision, recall, and F1 together) or for anything — a hyperparameter set, say — you don’t want silently mutated somewhere downstream.
Sets and dictionaries solve different problems again. A set strips
duplicates and gives near-instant membership testing, which matters
more than it sounds: checking word in vocab_list is O(n), but
word in vocab_set is O(1), and with a 50,000-word NLP vocabulary
that’s the difference between a fast pipeline and a slow one. A
dictionary is the natural shape for anything keyed by name — model
configs, label encoders, JSON responses — and pairs well with **kwargs
when you want to unpack a config straight into a model constructor.