Mixed Deck — All POC Topics Flashcards
100 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 20 Mixed Deck — All POC Topics flashcards as text
Which asyncio function is the standard entry point for running a top-level coroutine in Python 3.7+?
Answer: asyncio.run()
asyncio.run() creates a new event loop, runs the given coroutine until completion, and then closes the loop — it is the recommended entry point since Python 3.7.
What is the correct way to prevent SSRF in a Python application that fetches user-supplied URLs?
Answer: Validate and whitelist allowed hosts/IP ranges before making any outbound request
Whitelisting allowed hosts ensures the application cannot be tricked into making requests to internal network resources or cloud metadata endpoints.
What happens when you run `python -m module_name` instead of importing a module?
Answer: Python executes the module's `__main__` block as a script
The `-m` flag locates the named module and executes it as a script, triggering the `if __name__ == '__main__':` block.
What is the correct way to pin a package to an exact version in `requirements.txt`?
Answer: package==1.2.3
The `==` operator in `requirements.txt` pins to an exact version, ensuring reproducible installs.
Which method reads all lines of a text file into a list of strings?
Answer: readlines()
`readlines()` reads the entire file and returns each line as a string element in a list, including newline characters.
What is the primary purpose of a threading.Lock object in Python?
Answer: To synchronize access to shared resources, preventing simultaneous modification by multiple threads
A Lock ensures mutual exclusion — only one thread can acquire the lock at a time, preventing race conditions on shared data.
What does `collections.defaultdict(list)` do when a missing key is accessed?
Answer: Automatically creates an empty list for that key
`defaultdict` calls the factory function (`list`) to generate a default value for any missing key, avoiding KeyError.
When using `with open('file.txt') as f:`, what happens to the file when the block exits?
Answer: It is automatically closed
The context manager protocol calls `f.__exit__()`, which closes the file automatically even if an exception occurs.
Which Python library is most commonly used to automate interactions with Excel spreadsheets without needing Microsoft Office installed?
Answer: openpyxl
`openpyxl` reads and writes `.xlsx` files natively in pure Python, supporting formulas, charts, and cell styles without Office.
What does enabling `SECURE_HSTS_SECONDS` in a Python Django application accomplish?
Answer: Instructs browsers to only connect via HTTPS for the specified duration via a response header
Setting `SECURE_HSTS_SECONDS` causes Django to emit the `Strict-Transport-Security` response header, telling browsers to refuse HTTP connections for the configured period.
What is the time complexity of checking membership (`x in s`) in a Python set?
Answer: O(1) average
Sets are implemented as hash tables, giving average O(1) membership tests compared to O(n) for lists.
Which of the following demonstrates operator overloading in Python?
Answer: Defining `__add__` in a class so `+` works on custom objects
Operator overloading is achieved by implementing dunder methods like `__add__`, `__mul__`, etc., in a class.
What is the benefit of using `bisect` module for searching in a sorted list?
Answer: O(log n) binary search instead of O(n) linear scan
bisect implements binary search, halving the search space with each comparison and achieving O(log n) performance on pre-sorted lists.
Which method of a `logging.Logger` object logs a message only if the logger's effective level is DEBUG or lower?
Answer: logger.debug()
`logger.debug()` emits a log record at level DEBUG (10), the lowest standard level.
In Python's sqlite3 module, what object is used to execute SQL statements?
Answer: Cursor
A Cursor object obtained via connection.cursor() is used to execute SQL commands and fetch results.
What is the purpose of using `bcrypt` over plain SHA-256 for storing user passwords in Python?
Answer: bcrypt includes a work factor making it intentionally slow to resist brute-force
bcrypt's configurable work factor ensures hashing remains computationally expensive even as hardware improves, making large-scale cracking impractical.
What happens when you open a file with mode `'a'` and write to it?
Answer: Data is appended to the end of the file
Append mode (`'a'`) positions the write pointer at the end of the file, so new data is added after existing content.
What is the primary advantage of using SQLAlchemy's connection pooling over creating a new connection for each query?
Answer: It reuses existing database connections, reducing overhead
Connection pooling maintains a set of open connections that are reused, avoiding the cost of establishing a new TCP connection for every query.
Why is documenting troubleshooting steps important?
Answer: It creates a knowledge base for future similar issues and tracks what was tried
Documentation creates a valuable knowledge base, prevents repeating unsuccessful approaches, and provides accountability for changes made during troubleshooting.
Which Python design pattern allows you to add logging, caching, or validation behavior to a function without modifying its source code?
Answer: Decorator
Python's Decorator pattern (using @decorator syntax) wraps a callable to add behavior before or after the original function executes without changing its code.