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