Check your understanding of the primer: what dataclasses and lists are, and how they differ.

Question 1

Which of the following is a specific, composite data type in Python?

Select one answer, then check.

  • Not quite. An integer is one of the five primitive types the primer recaps; it is not composed of other types.
  • Correct. The primer's own bullet list calls a list "a new type that can hold multiple values of the same type" - it is a type in its own right, and a composite one.
  • Not quite. The primer describes a dataclass as "a way of making new types", not a type itself, so it is not a specific data type.
  • Not quite. Mutability is a property that lists and dataclasses share, not a data type on its own.

Question 2

What is a basic functional definition of Dataclasses?

Select one answer, then check.

  • Correct. The primer describes a dataclass as "a way of making new types that combine multiple bits of different kinds of data into one bundle" - a collection of named values standing in for one thing.
  • Not quite. The primer draws exactly this contrast: a list is "a new type", while a dataclass is "a way of making new types" and not a type itself.
  • Not quite. Dataclasses are presented as a new, additional capability this chapter introduces, not a long-standing structure like a list or a dictionary.
  • Not quite. A dataclass is the definition used to create instances, not an instance itself.

Question 3

Which of the following is NOT true about Lists?

Select one answer, then check.

  • Not quite, this is true. The primer says the elements of a list "should all be of the same type, which becomes the element type of the list."
  • Not quite, this is true. The primer's Lists example creates every list with square brackets, such as scores = [100, 95, 33, 85].
  • Not quite, this is true. The primer's own example includes empty = [].
  • Correct, this is the false statement. Every list the primer shows has a fixed, finite number of elements, including the empty list.