Check your understanding of the previous reading: the list type, its element type, empty lists, and how list-creation brackets differ from indexing brackets.

Question 1

Identify each of the following as a Primitive Type, a Composite Type, or Not a Type.
None
True
List
Integer

Question 2

What is the type of the following literal value?

[4.5, 3.2, 7.3]

Select one answer, then check.

  • Correct. Square brackets on their own always create a list, no matter what the element type is.
  • Not quite. Float is the element type of this list, not the type of the whole value.
  • Not quite. There are no integers here at all - every value has a decimal point.
  • Not quite. There are no quotes here, so none of these values are strings.
  • Not quite. None of the values are True or False.
  • Not quite. The literal value is a list of three floats, not the special None value.

Question 3

What is the element type of the following literal value?

[4.5, 3.2, 7.3]

Select one answer, then check.

  • Not quite. List is the type of the whole value, not the type of what's inside it.
  • Correct. Every element (4.5, 3.2, 7.3) is a decimal number, so the element type is Float.
  • Not quite. Each element has a decimal point, so it's a Float, not an Int.
  • Not quite. There are no quotes around any of the elements.
  • Not quite. None of the elements are True or False.
  • Not quite. Every element is a number; none of them are the special None value.

Question 4

True or false: Lists can also be correctly referred to as "Arrays" or "Vectors".

Select one answer, then check.

  • Not quite. The reading is explicit that "Array" and "Vector" describe slightly different concepts, and asks you not to use those words for a Python list.
  • Correct. "List" is the correct term in this course; "Array" and "Vector" are related but different concepts.

Question 5

Which of the following are possible element types for a list?

Select every answer that applies, then check.

  • Correct. A list can hold floats, just like [4.5, 3.2, 7.3].
  • Correct. A list can hold strings, just like ["Apples", "Oranges", "Bananas"].
  • Correct. A list can hold booleans, just like [True, False, True].
  • Correct. A list's elements can themselves be lists - lists can be nested inside of other lists.

Question 6

True or false: Lists and strings are both sequences of data.

Select one answer, then check.

  • Correct. This reading already indexes and subscripts lists with the exact same square-bracket rules used for strings, because both are sequences of values.
  • Not quite. Strings and lists share indexing, subscripting, and membership-testing rules precisely because both are sequences.

Question 7

Identify each of the following as a "List literal" or "String indexing".
[]
"Hermione"[1]
["Hermione"]
[1]
""[1]