← All Python Flashcard Decks

Python Flashcards

7 cards from real Python practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Python flashcards as text
  1. What does the `*args` syntax in a function definition allow?

    Answer: Accept any number of positional arguments

    `*args` collects extra positional arguments into a tuple inside the function.

  2. Which method removes and returns the last element of a Python list?

    Answer: pop()

    `list.pop()` removes and returns the last element by default, or an element at a given index.

  3. What is the output of `bool([])` in Python?

    Answer: False

    An empty list is falsy in Python, so `bool([])` returns `False`.

  4. Which keyword is used to define a generator function in Python?

    Answer: yield

    Using `yield` instead of `return` makes a function a generator that produces values lazily.

  5. What does the `is` operator check in Python?

    Answer: Object identity

    `is` checks whether two variables refer to the exact same object in memory, not just equal values.

  6. What will `list(range(1, 10, 3))` produce?

    Answer: [1, 4, 7]

    `range(1, 10, 3)` starts at 1, steps by 3, and stops before 10: 1, 4, 7.

  7. Which of the following is a mutable data type in Python?

    Answer: list

    Lists are mutable — their elements can be changed after creation, unlike tuples, strings, and frozensets.