Core Python Programming Concepts Flashcards
7 cards from real POC practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Core Python Programming Concepts flashcards as text
What is the output of `bool([])` in Python?
Answer: False
An empty list is falsy in Python, so `bool([])` evaluates to False.
Which statement about Python's `with` statement is correct?
Answer: It automatically calls __enter__ and __exit__ on a context manager
The `with` statement invokes `__enter__` at the start and guarantees `__exit__` is called when the block ends, even if an exception occurs.
What is the result of `'hello'[1:4]`?
Answer: 'ell'
Slice notation [1:4] returns characters at indices 1, 2, and 3, which are 'e', 'l', 'l' → 'ell'.
Which built-in function returns an iterator of (index, value) pairs?
Answer: enumerate()
`enumerate()` wraps an iterable and yields (index, value) tuples for each element.
What happens when you raise an exception without an argument inside an `except` block?
Answer: The caught exception is re-raised
A bare `raise` inside an `except` block re-raises the currently handled exception with its original traceback.
Which of the following is a mutable data type in Python?
Answer: list
Lists are mutable; their elements can be added, removed, or changed after creation, unlike tuples, frozensets, and strings.
What is the output of `print(10 // 3)`?
Answer: 3
The `//` operator performs floor division, discarding the remainder and returning the integer quotient.