PCAP Cheat Sheet 2026
The 30 highest-yield PCAP facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
40 questions
65 min time limit
70% to pass
- A property setter is defined by applying which decorator to a second method with the same name as the getter? → @.setter
- What does the `'b'` flag in `open('file', 'rb')` indicate? → Binary mode
- What is the correct syntax to create a tuple in Python? → tuple = (1, 2, 3)
- Which data structure is used to store a sequence of items that are ordered and changeable in Python? → List
- Which of the following is used to define a function in Python? → def
- What is the `nonlocal` keyword used for inside a nested function? → To modify a variable defined in the nearest enclosing non-global scope
- Which exception is raised when you try to open a file that does not exist? → FileNotFoundError
- Which built-in function returns the number of items in a container? → len()
- What does `os.path.join('folder', 'file.txt')` return on Linux? → folder/file.txt
- How do you create a list in Python? → list = [1, 2, 3]
- What does `abs(-5)` return? → 5
- What happens if an exception is raised inside a `finally` block? → It replaces any previously raised exception
- Which of the following is a valid variable name in Python? → variable_ name
- How do you check if a key exists in a dictionary? → if key in dict:
- What does `except Exception as e:` allow you to do? → Access the exception object via the variable `e`
- What does the `@classmethod` decorator do? → Passes the class as the first argument instead of the instance
- How do you define a class variable (shared by all instances) in Python? → Declare it outside any method, inside the class body
- What does `file.readlines()` return? → A list of strings, one per line
- What does the `__name__ == '__main__'` guard do? → Prevents code from running when the module is imported
- Which dunder method allows an object to be represented as a string when printed? → __str__
- What does `sorted()` return? → A new sorted list
- What does the `enumerate()` function return when iterating? → A tuple of (index, value)
- Which module provides `namedtuple` for creating tuple subclasses with named fields? → collections
- Which function from the `os` module returns the current working directory? → os.getcwd()
- Which built-in decorator marks a method that receives the class object (not an instance) as its first implicit argument? → @classmethod
- What is a closure in Python? → A function that captures variables from its enclosing scope
- What is the base class for all built-in exceptions in Python? → BaseException
- Which exception is raised when accessing an index that does not exist in a list? → IndexError
- What does `functools.wraps` do when used in a decorator? → Preserves the original function's metadata
- What does the `copy` module's `deepcopy()` function do? → Recursively copies an object and all objects it references
Turn these facts into recall: