← All POC Flashcard Decks

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
  1. What is the output of `print(type(lambda x: x))`?

    Answer:

    Lambda expressions create anonymous function objects, so their type is 'function'.

  2. Which of the following correctly unpacks a dictionary into keyword arguments?

    Answer: func(**my_dict)

    The `**` operator unpacks a dictionary into keyword arguments when calling a function.

  3. What does the `global` keyword do inside a function?

    Answer: Declares that a variable refers to the global scope

    The `global` keyword tells Python to use the variable from the global (module-level) scope rather than creating a local one.

  4. What is the result of `[x**2 for x in range(4) if x % 2 == 0]`?

    Answer: [0, 4]

    range(4) gives 0,1,2,3; filtering even values gives 0 and 2; squaring gives [0, 4].

  5. Which exception is raised when accessing a dictionary key that does not exist?

    Answer: KeyError

    Python raises a KeyError when you attempt to access a dictionary with a key that is not present.

  6. What is the purpose of `__init__` in a Python class?

    Answer: It initializes a new instance of the class

    `__init__` is a special method called automatically when a new object is instantiated to set up its initial state.

  7. What does `*args` allow a function to accept?

    Answer: An arbitrary number of positional arguments

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