CT: Comprehensive Prerequisites Guide

IMPORTANT

Goal: CT doesn’t need advanced math. It needs Logic and Attention to Detail.


1. Logic Basics

1.1 True vs False

  • True: Yes, Correct, On.
  • False: No, Incorrect, Off.
  • Comparison:
    • is True.
    • is False.

1.2 Logical Operators

  1. AND: Both must be True.
    • “I will go IF it is sunny AND I have money.”
  2. OR: At least one must be True.
    • “I will eat IF it is Pizza OR Burger.”
  3. NOT: Opposite.
    • “NOT True” is False.

2. Arithmetic Basics

2.1 Operations

  • Add/Sub/Mul: , , .
  • Division: /. (e.g., ).
  • Modulus (): The Remainder.
    • (Because ).
    • Use Case: Checking Even/Odd ().

2.2 Precedence (BODMAS)

  1. Brackets.
  2. Orders (Powers).
  3. Division / Multiplication (Left to Right).
  4. Addition / Subtraction (Left to Right).

3. The “State” Concept

  • Variable State: A variable has one value at any specific moment.
  • History: It doesn’t remember what it was 5 minutes ago.
  • Overwrite: A = 5, then A = 10. The 5 is gone forever.

4. Common Pitfalls

  1. Assignment vs Equality:
    • A = 10 (Action: Make A 10).
    • A == 10 (Question: Is A 10?).
  2. Infinite Loops:
    • Forgetting to update the variable in a while loop.
  3. Off-by-One:
    • Lists start at Index 0.
    • The last item is at Index Length - 1.