Which of the following is a collection in Python?

2026

Which of the following is a collection in Python?

  1. A.

    int

  2. B.

    float

  3. C.

    bool

  4. D.

    str

Attempted by 308 students.

Show answer & explanation

Correct answer: D

In Python, data types are categorized as scalar or collection types. Integers (int), floats (float), and booleans (bool) are scalar types that store single values. Strings (str) are sequences of characters and support iteration, containment checks, and length operations, making them a collection type. Therefore, the string is the correct answer.

Explore the full course: Rssb Senior Computer Instructor