What is the primary difference between a tuple and a list in Python?
- Tuples are mutable, and lists are immutable.
- Lists are ordered, and tuples are unordered.
- Tuples are immutable, and lists are mutable.
- Lists can store elements of different data types, while tuples cannot.
The correct option is 3. Tuples in Python are immutable, meaning their elements cannot be changed after creation, whereas lists are mutable and can be modified.
Loading...
Related Quiz
- The ____ function in the functools module is used to transform a method into a class method decorator.
- In machine learning, ____ is a technique used to choose the hyperparameters for a given model.
- Which built-in Python function can be used to determine if a class is a subclass of another?
- If a derived class does not have its constructor, which constructor gets called when an object of the derived class is instantiated?
- What does the as keyword do in the context of importing modules in Python?