Modules, Libraries & Debugging 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 Modules, Libraries & Debugging flashcards as text
What does the `warnings.warn()` function do?
Answer: Issues a warning message that can be filtered or suppressed
`warnings.warn()` emits a warning that by default prints to stderr but does not interrupt program execution.
Which `pathlib.Path` method checks whether a path points to an existing file?
Answer: Path.is_file()
`Path.is_file()` returns `True` if the path exists and is a regular file.
When Python caches a compiled module, where does it store the `.pyc` file?
Answer: In a `__pycache__` subdirectory
Python 3 stores bytecode-compiled `.pyc` files inside a `__pycache__` directory relative to the source file.
Which `json` module function serializes a Python object to a JSON-formatted string?
Answer: json.dumps()
`json.dumps()` converts a Python object to a JSON string ('s' = string); `json.dump()` writes to a file.
What is the output of `print(type(collections.namedtuple('Point', ['x','y'])))`?
Answer:
`namedtuple()` returns a new class (a `type` object), not an instance of that class.
Which `pdb` command steps INTO the next function call during debugging?
Answer: step (s)
The `s` (step) command executes the current line and stops at the first possible statement inside a called function.
What does `functools.lru_cache` do when applied as a decorator?
Answer: Caches the return values of a function based on its arguments
`lru_cache` memoizes function results using a Least Recently Used cache, avoiding redundant computation for repeated inputs.