In Python, ........... is the type of sequence that resembles a list, except…

2024

In Python, ........... is the type of sequence that resembles a list, except that, unlike a list, it is immutable.

  1. A.

    Vector

  2. B.

    Object

  3. C.

    Dictionary

  4. D.

    Tuple

Attempted by 998 students.

Show answer & explanation

Correct answer: D

Explanation

In Python, data structures are categorized based on their mutability and functionality. The question asks for a sequence type that is similar to a list but immutable.

Analysis of Options

  • Vector: Python does not have a built-in 'Vector' type. Vectors are typically found in other languages like C++ or implemented via libraries in Python.

  • Object: This is a general term for any instance of a class. It is not a specific sequence type.

  • Dictionary: Dictionaries store key-value pairs and are mutable, meaning their contents can be modified after creation.

  • Tuple: Tuples are ordered sequences like lists but are immutable. Once a tuple is created, its elements cannot be changed.

Conclusion

The correct answer is Tuple, as it is the only sequence type listed that is immutable.

Explore the full course: Hpsc Pgt Computer Science