Week 5: String Predicates and Equality Checks
218 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 5: String Predicates and Equality Checks > **Course:** Jan 2026 - Python > **Focus:** Reading constraints on strings, then comparing structured data carefully. --- ## 1.

Visual strip
Relevant recall pieces for this note
Week 5: String Predicates and Equality Checks
Course: Jan 2026 - Python Focus: Reading constraints on strings, then comparing structured data carefully.
1. Core idea
Week 5 is about deciding whether something satisfies a rule, and whether two structured objects are exactly equal.
What to remember
- Predicate functions should return
TrueorFalse. - A valid word check often means:
- no spaces,
- first character uppercase,
- remaining characters lowercase.
- Matrix equality needs both shape and element-by-element matching.
- List equality is order-sensitive.
2. Common traps
- Checking only size is not enough.
- Checking only membership is not enough.
- If one mismatch is found, return
Falseimmediately. - A recursive equality function still needs a base case.
3. Speedrun pattern
When you see a Week 5 question, ask:
- Is this a validator or a comparator?
- Does the structure have to match exactly, or only loosely?
- Can I stop as soon as the first mismatch appears?
4. Micro revision
- Predicate = returns Boolean
- Equality = same shape + same values + same order
- Early exit is your friend
Assignment anchor
Navigation
- Previous: Week 4 Notes
- Next: Week 6 Notes