← All PCAP Flashcard Decks

Functions and Modules Flashcards

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

Read the first 6 Functions and Modules flashcards as text
  1. What is a recursive function?

    Answer: A function that calls itself

    A recursive function is one that calls itself, with a base case to terminate the recursion.

  2. What does `functools.wraps` do when used in a decorator?

    Answer: Preserves the original function's metadata

    `functools.wraps` copies the original function's `__name__`, `__doc__`, etc. to the wrapper function.

  3. What is the `nonlocal` keyword used for?

    Answer: Referring to a variable in the nearest enclosing non-global scope

    `nonlocal` allows an inner function to modify a variable in the nearest enclosing scope (not global).

  4. Which built-in function filters elements of an iterable based on a function?

    Answer: filter()

    `filter()` returns an iterator of elements for which the function returns True.

  5. What does `__all__` in a module control?

    Answer: Which names are exported when `from module import *` is used

    `__all__` is a list that defines the public interface of a module for wildcard imports.

  6. What is the difference between a `return` and `yield` in a function?

    Answer: `return` exits the function; `yield` pauses and resumes it

    `return` terminates the function entirely while `yield` suspends it and can resume on the next call.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. pythoninstitute.org — Eligibility, fees, retake fee, retake policy, score release, time limit, score validity · verified Nov 2026
  2. home.pearsonvue.com — Test delivery · verified Nov 2026