BACK TO COMMAND CENTER
PCEP SURVIVAL WALL ANDY'S EDITION V2.0

1. Python Object Hierarchy

VALUE TYPES
├── IMMUTABLE (Cannot change value in-place)
│   ├── int    ──> 42, -5, 0o12 (Octal), 0x2A (Hex)
│   ├── float  ──> 3.14, -0.0, 2e3 (= 2000.0)
│   ├── bool   ──> True, False [True == 1, False == 0]
│   ├── str    ──> "Andy", 'PCEP', \"\"\"Multi-line\"\"\"
│   └── tuple  ──> (1, 2), (5,) [🚨 Needs trailing comma!]
└── MUTABLE (Can change value in-place)
    ├── list   ──> [1, 2, 3], ['x', 'y']
    ├── dict   ──> {"key": "value"}, {1: "one"}
    └── set    ──> {1, 2, 3}
└── SPECIAL
    └── None   ──> None (Absence of value)
🚨 Exam Data Type Disguises Literals containing a dot or exponent are always floats (e.g. 1. or 2e0 are floats, not ints). Modifying an immutable tuple item directly via index (t[0] = 1) causes a TypeError.

2. Variable / Value Assignment Decoder

x = 42
Token PCEP Term Exam Role
x Variable Name assigned to a value object.
= Assignment Binds name on the left to value on the right.
42 Value The concrete data payload held in memory.
💥 Variable ≠ Value Changing a variable (x = 20) does not change the initial value object (42); it just reassigns the name label to point somewhere else.

3. Function Anatomy Decoder

[ DEFINITION SIGNATURE ]
 def   add ( a , b ) :
  │     │   └───┬───┘
  │     │       └─ PARAMETERS (Placeholders inside signature)
  │     └─ FUNCTION NAME (Identifier)
  └─ KEYWORD (Starts block definition)

     return   a + b
       │       ──┬──
       │         └─ EXPRESSION (Evaluates to a value)
       └─ KEYWORD (Exits function, sends value back)

[ CALL & ASSIGNMENT ]
 result   =   add ( 2 , 3 )
   │      │    │    ──┬──
   │      │    │      └─ ARGUMENTS (Actual values passed to call)
   │      │    └─ FUNCTION CALL
   │      └─ ASSIGNMENT OPERATOR
   └─ VARIABLE (Receives return value)
🔄 Visual Call Flow Trace 1. Code hits: result = add(2, 3)
2. Arguments map to parameters → a=2, b=3.
3. Expression runs: 2 + 3 evaluates to 5.
4. return 5 stops function execution and sends 5 back.
5. Variable result is assigned the integer value 5.

4. Parameter vs Argument

 DEFINITION BLOCK         EXECUTION CALL
 def greet(name):          greet("Andy")
             │                     │
             ▼                     ▼
       [ PARAMETER ]         [ ARGUMENT ]
         Placeholder           Actual Value
💡 Mnemonic: PARAMETER = PLACEHOLDER • ARGUMENT = ACTUAL VALUE

Positional: Mapped strictly by relative order. f(2, 3)a=2, b=3.
Keyword: Assigned explicitly by name. f(b=3, a=2) overrides order safely.

🔥 Positional Follows Keyword Rule Positional arguments MUST ALWAYS precede keyword arguments inside any call statement!
print("Hi", end="", "World") → ❌ SyntaxError: positional argument follows keyword argument

5. String Methods Survival Box

Method Syntax Output Value Exam Trap / Behavior
"hi".upper() "HI" Strings are immutable; methods return a new string string. Original stays lowercase.
"HI".lower() "hi" Converts all casing characters to lowercase.
"txt".replace("t","x") "xxxl" Replaces all occurrences of the substring character.
"banana".find("an") 1 Returns lowest starting index. Returns -1 if substring is missing!
"a,b".split(",") ['a', 'b'] Splits string into a list of strings at delimiter points.
"-".join(['a', 'b']) "a-b" Joins list elements into string using separator. Fails if items are not strings!

6. Truthy vs Falsy Sector

Strictly Falsy Values Checklist:
FalseNone
0 (int) • 0.0 (float)
"" (empty string) • [] (empty list)
{} (empty dict) • set() (empty set)
💡 Rule: Everything else is True! Non-empty string literals evaluate to True regardless of text content value.
bool("False")Truebool("0")True

7. Core Scopes & PCEP Terminology Matrix

Global Scope: Variables defined outside functions. Visible everywhere inside file. Local Scope: Variables defined inside a function block. Visible only within that function execution context. Shadowing: Variable assigned inside function automatically becomes local, masking global variables. Global stays 10: x=10; def f(): x=5 Keyword: Reserved word token with a fixed syntactical purpose (def, while, etc.). Can never be variable identifiers!
PCEP SURVIVAL WALL ANDY'S EDITION V2.0

1. Loops Dedicated Review

A. FOR LOOP (Loops through a sequence)

for x in range(3):
    print(x)
Translation: FOR EACH VALUE IN A SEQUENCE → DO SOMETHING.

B. WHILE LOOP (Repeats based on condition)

while x < 3:
    x += 1
Translation: REPEAT AS LONG AS CONDITION IS TRUE.

C. Loop Control Commands

break → Exits the loop completely and immediately.
continue → Skips remaining code inside current iteration.
pass → Null placeholder instruction. Does absolutely nothing.
🚨 Infinite Loop & Update Traps • Loops hang forever if conditional parameters never evaluate to False.
• **Exam Trap:** Forgetting to update counter variables (x += 1) creates infinite runs.
• **Exam Trap:** continue immediately skips the rest of the current loop layer code block.

2. range() Exploration Terminal

MANTRA: START INCLUDED ── STOP EXCLUDED
range(stop)             ──> Starts at 0, steps 1.
range(start, stop)      ──> Explicit start, steps 1.
range(start, stop, step)──> Moves by step factor.
Syntax Example Generated Sequence Values
range(5)0, 1, 2, 3, 4
range(1, 5)1, 2, 3, 4
range(2, 13, 3)2, 5, 8, 11
range(1, 2)1
range(5, 1, -1)5, 4, 3, 2 (Counts down backward)
🚨 THE ABSOLUTE STOP VAL BOUNDARY RULE THE STOP VALUE NEVER APPEARS IN THE OUTPUT SEQUENCE.
range(1, 5) will generate up to 4. It never yields 5. If increments are impossible (range(1, 5, -1)), it yields an empty loop without throwing errors.

3. Data Structures Comparison Matrix

Type Syntax Ordered Mutable Duplicates
list [1, 2] YES YES YES
tuple (1, 2) YES NO YES
dict {"k":v} NO YES Keys: NO
set {1, 2} NO YES NO

Common List Manipulation Methods:

.append(x) → Adds item to the very end of list.
.insert(i, x) → Adds item at specific index position.
.remove(x) → Removes first matching value. Throws error if missing!
.pop(i) → Removes and returns item at index (defaults to end).
🚨 Empty Structures & Single Item Traps{} creates an empty dictionary, NOT a set!
set() is required to instantiate an empty set.
(5) evaluates as plain integer. Single item tuples require trailing commas: (5,).

4. Sequence Slicing & Built-In Helper Checklist

Slicing Axiom: seq[start:stop:step] → Start included, stop excluded. "PCEP"[1:3] yields "CE". Indexing starts at 0. Tolerance: Out-of-bounds slices clip cleanly instead of throwing error crashes: [1, 2][0:99] safely returns [1, 2]. Core Helpers: len() returns element count. type() checks type classes. print() outputs strings but returns None! User Input: input() always captures keyboard data streams as a str string, requiring manual numeric conversions.
PCEP SURVIVAL WALL ANDY'S EDITION V2.0

1. Precedence Ladder & Identity

1 (HIGH)( )Parentheses override everything.
2**🚨 Power runs Right-to-Left: 2**3**2 = 2**(3**2) = 512.
3+x, -xUnary signs. Right of power wins: 2**-2 = 0.25.
4*, /, //, %Multiplicative math. Evaluates Left-to-Right.
5+, -Additive math layers (Binary plus and minus).
6<<, >>Bitwise Logical Left/Right Shifts.
7& → ^ → |Bitwise operations hierarchy ordering (AND → XOR → OR).
8==, is, inEquality value match, Identity match, Membership match.
9 (LOW)not → and → orLogical boolean layer evaluation stack order (NOT → AND → OR).

Practical Priority Examples:

3 << 2 | 1 → Shifts first (3 × 4 = 12), then runs bitwise OR (12 | 1) → 13.
2 + 3 * 4 → Multiplies first (3 × 4 = 12), then adds 2 → 14.
🚨 Identity vs Parity Equality== checks if values are equal. • is checks strict unique address identities.
in / not in evaluate membership existence inside sequence iterables.

2. Common PCEP Question Decoder

  • list vs tuple
  • When you see...What is the exam testing?
    def / returnFunction declaration parameters and immediately exiting value loops.
    range(x, y)Loop constraints boundary loops. Target y is excluded!
    Mutability differences. Modifying tuple indexes throws errors.
    is vs ==Address location identity vs simple content value matching.
    try / exceptCatching runtime issues safely before scripts crash out.
    << / >>Fast binary bit manipulation operations (multiplication/floor division).

    3. Bitwise Survival Matrix (4-Bit Pilot)

    Dec8421Binary Dec8421Binary
    000000b0000810000b1000
    100010b0001910010b1001
    200100b00101010100b1010
    300110b00111110110b1011
    401000b01001211000b1100
    501010b01011311010b1101
    601100b01101411100b1110
    701110b01111511110b1111
    & = COMMON BITS: 1 only if BOTH bits are 1. 10 & 128.
    | = ALL BITS: 1 if at least one side is 1. 10 | 1214.
    ^ = DIFFERENT BITS ONLY: 1 if bit states differ. 10 ^ 126.
    << Left Shift: Multiply left side by 2right. 2 << 32 × 8 = 16.
    >> Right Shift: Floor divide left side by 2right. 11 >> 211 // 4 = 2.
    🚨 Unary Operator Asterisk Reject Multiplication symbols (*) are strictly binary. Running print(*5) triggers a fatal syntax block crash!

    4. Exception Architecture Decoder

    try:
        # Code execution lines run path here.
    except ArithmeticError:
        # Catches parent groups and subclass children!
    except ZeroDivisionError:
        # 🚨 This line is dead block if placed below parent!
    finally:
        # Guaranteed line execution regardless of errors.

    5. High-Frequency Core 6 Errors

    Error Name Common Cause / Example
    NameErrorUsing variable before definition. print(undef)
    ValueErrorRight type, wrong internal value context. int("xyz")
    TypeErrorOperation applied to incompatible types. len(42)
    IndexErrorSequence array lookup index out of bounds. [1][9]
    KeyErrorTarget key lookup missing from dictionary. {}["k"]
    ZeroDivisionErrorDividing evaluation by zero or zero floats. 1 / 0.0

    🚨 The Ultimate Exam Room Traps Checklist (Review Right Before Entering!)

    Identifier vs Value: Changing label bindings via assignment does not mutate old data inside memory structures.
    Parameter vs Argument: Parameters act as labels inside definitions; arguments provide raw value inputs inside call blocks.
    Print vs Return: print() shows visual outputs but evaluates to None. Only return chains active object payloads out.
    Finite range() Exclusions: range(5) yields 0,1,2,3,4. The stop value 5 is never generated or accessed.
    Float-String roadblocks: Running int("5.5") breaks with a ValueError. Change down sequentially: int(float("5.5")).
    Missing Tuple Comma: Coding x = (5) instantiates an integer. Single items require trailing commas: x = (5,).
    Case Sensitivities: Tokens like true or none are valid variable labels. Only True, False, and None are keywords.
    Default Parameter Constraints: Preset positional parameters (def f(a, b=2):) must sit strictly behind raw variable placeholders.
    Bitwise vs Logical: and/or short-circuit boolean valuations. &/| evaluate individual bits step-by-step.