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 does the `pass` statement do in Python?
Answer: Acts as a no-operation placeholder
`pass` is a null statement that does nothing, used where syntax requires a statement but no action is needed.
How do you create a generator function in Python?
Answer: Use the `yield` keyword inside a function
A function containing at least one `yield` statement becomes a generator function that returns a generator iterator.
What is the output of `sorted([3, 1, 2], reverse=True)`?
Answer: [3, 2, 1]
`sorted()` with `reverse=True` returns a new list sorted in descending order.
Which method removes and returns an element from a set by arbitrary choice?
Answer: set.pop()
`set.pop()` removes and returns an arbitrary element; `remove()` requires a specific value and `discard()` doesn't return it.
What is the difference between `is` and `==` in Python?
Answer: `is` compares identity, `==` compares values
`is` checks if two variables point to the same object in memory, while `==` checks if their values are equal.
What does `str.join()` do?
Answer: Concatenates an iterable of strings using str as a separator
`separator.join(iterable)` concatenates all strings in the iterable, inserting the separator between each pair.
What is the output of `list(map(str, [1, 2, 3]))`?
Answer: ['1', '2', '3']
`map(str, [1,2,3])` applies `str()` to each element, converting integers to strings, resulting in ['1','2','3'].