Free Online Flashcard Deck

5 Collections and String Processing Free Online FlashCards

Study 5 Collections and String Processing with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What does it mean that Python strings are immutable?

Back

A string is an immutable sequence of Unicode characters, so operations that seem to modify it return a new string.

02
Front

How does Python index sequence elements?

Back

Python uses zero-based indexing: the first element is at index 0, and index -1 refers to the final element.

03
Front

What do the parts of a Python slice mean?

Back

In sequence[start:stop:step], start is included, stop is excluded, and step controls how far the index advances.

04
Front

How do append() and extend() differ?

Back

append() adds one item to the end; extend() adds every item from an iterable.

05
Front

What is a Python tuple?

Back

A tuple is an ordered, immutable sequence, making it suitable for fixed groups of related values.

06
Front

How can you safely read a possibly missing dictionary key?

Back

A dictionary subscription for a missing key raises KeyError; get() can return None or a supplied default instead.

07
Front

What are the defining properties of a Python set?

Back

A set stores distinct, hashable values and does not support indexing or slicing.

08
Front

When should you use discard() instead of remove()?

Back

remove() raises an error if the value is absent; discard() does nothing when the value is absent.

09
Front

What does enumerate() provide during iteration?

Back

enumerate() supplies both the index and the value while iterating, such as for index, color in enumerate(colors).

10
Front

What is zip() used for?

Back

zip() pairs corresponding elements from multiple iterables, allowing loops such as for name, age in zip(names, ages).

11
Front

What is the general form of a list comprehension?

Back

A list comprehension follows [expression for item in iterable if condition], with the if clause optional.

12
Front

How does a dictionary comprehension construct entries?

Back

A dictionary comprehension uses a key–value expression, such as {number: number ** 2 for number in range(5)}.