Embercode
✕
Built-in CollectionsQuick quiz

Immutable values and type hints

7 questions. Covers Type hints and generics in Python.

Questions 1 to 5 of 7

  1. 1. Which call gives a value whose items cannot be changed, and which stays the same even if the original list changes later?
  2. 2. Which statement about tuples is correct?
  3. 3. True or false: frozenset([1, [2]]) raises an error, because a list cannot be stored in a set.
  4. 4. True or false: a function that appends to the list it receives also changes the caller's list.
  5. 5. The caller builds a list of songs, makes a Playlist from it, and then calls caller.append('Outro'). What is the bug in this class? ``python class Playlist: def __init__(self, songs): self.songs = songs def get_songs(self): return self.songs ``

5 question(s) left on this page.