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
  1. A property setter is defined by applying which decorator to a second method with the same name as the getter? @.setter
  2. What does the `'b'` flag in `open('file', 'rb')` indicate? Binary mode
  3. What is the correct syntax to create a tuple in Python? tuple = (1, 2, 3)
  4. Which data structure is used to store a sequence of items that are ordered and changeable in Python? List
  5. Which of the following is used to define a function in Python? def
  6. What is the `nonlocal` keyword used for inside a nested function? To modify a variable defined in the nearest enclosing non-global scope
  7. Which exception is raised when you try to open a file that does not exist? FileNotFoundError
  8. Which built-in function returns the number of items in a container? len()
  9. What does `os.path.join('folder', 'file.txt')` return on Linux? folder/file.txt
  10. How do you create a list in Python? list = [1, 2, 3]
  11. What does `abs(-5)` return? 5
  12. What happens if an exception is raised inside a `finally` block? It replaces any previously raised exception
  13. Which of the following is a valid variable name in Python? variable_ name
  14. How do you check if a key exists in a dictionary? if key in dict:
  15. What does `except Exception as e:` allow you to do? Access the exception object via the variable `e`
  16. What does the `@classmethod` decorator do? Passes the class as the first argument instead of the instance
  17. How do you define a class variable (shared by all instances) in Python? Declare it outside any method, inside the class body
  18. What does `file.readlines()` return? A list of strings, one per line
  19. What does the `__name__ == '__main__'` guard do? Prevents code from running when the module is imported
  20. Which dunder method allows an object to be represented as a string when printed? __str__
  21. What does `sorted()` return? A new sorted list
  22. What does the `enumerate()` function return when iterating? A tuple of (index, value)
  23. Which module provides `namedtuple` for creating tuple subclasses with named fields? collections
  24. Which function from the `os` module returns the current working directory? os.getcwd()
  25. Which built-in decorator marks a method that receives the class object (not an instance) as its first implicit argument? @classmethod
  26. What is a closure in Python? A function that captures variables from its enclosing scope
  27. What is the base class for all built-in exceptions in Python? BaseException
  28. Which exception is raised when accessing an index that does not exist in a list? IndexError
  29. What does `functools.wraps` do when used in a decorator? Preserves the original function's metadata
  30. What does the `copy` module's `deepcopy()` function do? Recursively copies an object and all objects it references
Turn these facts into recall: