PCEP Cheat Sheet 2026

The 30 highest-yield PCEP facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.

30 questions
40 min time limit
70% to pass
  1. What is the result of str(100) in Python? "100" (a string)
  2. What is the scope of a variable defined inside an if block at module level? Module (global) scope — if blocks don't create a new scope
  3. Which of the following correctly uses `break` inside a `while` loop? while True: break
  4. What is printed by the following code? for i in range(10): if i % 2 == 0: continue if i > 6: break print(i) 1 3 5
  5. What does the finally clause do in Python exception handling? Executes code regardless of whether an exception occurred
  6. What is the result of `10 // 3 + 1`? 4
  7. What does the following snippet output? try: pass except Exception: print('error') else: print('ok') ok
  8. What is the output of this code snippet? ```python var = 100 def my_func(): global var var = 50 my_func() print(var) ``` 50
  9. Which statement correctly describes when the `else` block of a `while` loop executes? When the while condition becomes False naturally
  10. Which keyword exits a loop and causes its `else` block to be skipped? break
  11. What type of error occurs if you try to access an undefined variable? NameError
  12. Does `continue` prevent the `else` block of a loop from executing? No, continue does not affect the else block
  13. What does `pass` do when used inside a loop body? Does nothing; acts as a placeholder
  14. Which of the following set operations returns elements in the first set but NOT in the second? Difference (`-`)
  15. Which escape sequence represents a newline character in a Python string? \n
  16. What is the output of `print(bin(10 >> 1))`? 0b101
  17. How do you define a function in Python? def myFunction():
  18. Which of the following is a valid Python identifier? _count
  19. Which operator has the highest precedence in Python? **
  20. Which of the following is a correct way to swap the values of two variables `a` and `b` in Python? a, b = b, a
  21. Which of the following Python expressions correctly calculates the length of a string? len(string)
  22. What is printed by this code? x = 10 while x > 0: x -= 3 if x == 1: break else: print('finished') Nothing
  23. What is the result of `0xFF & 0x0F`? 0x0F
  24. What is the result of the bitwise XOR operation `13 ^ 7`? 10
  25. What is `~(-1)` in Python? 0
  26. What does this code print? primes = [2, 3, 5] for p in primes: if p > 4: break else: print('all small') print('checked') checked
  27. What is the result of int(3.9) in Python? 3 (truncates toward zero)
  28. What exception is raised when a variable is referenced before it has been assigned a value? NameError
  29. Which bitwise operator would you use to check whether the 3rd bit (value 4) of integer x is set? x & 4
  30. What does `'Hello World'.lower()` return? hello world
Turn these facts into recall: