Chapter 15: Operators, Keywords, and Variables
Learning with AI as Your Partner
In Chapter 14, you learned about Python's core data types and how to store data in variables with type hints. Now it's time to learn what you can DO with that data using operators—the symbols that tell Python to perform actions.
What You'll Learn
By the end of this chapter, you will:
- Perform calculations with arithmetic operators (
+,-,*,/,//,%,**) - Ask True/False questions with comparison operators (
==,!=,>,<,>=,<=) - Combine conditions with logical operators (
and,or,not) - Update variables with assignment operators (
=,+=,-=,*=,/=) - Recognize Python's 35 reserved keywords and avoid using them as variable names
- Build a complete calculator integrating all operator types with type validation
AI-Native Learning Approach
This chapter teaches operators through AI partnership, not syntax memorization:
- Understand the concept: Learn what operators do, not just their syntax
- Explore with AI: Ask "Why does Python have both
/and//?" instead of memorizing rules - Validate with type(): See how operators affect types (
int / int→float) - Learn from errors: When
ZeroDivisionErroroccurs, ask AI "why and how to prevent it?"
Chapter Structure
Lesson 1: Arithmetic Operators — Doing Math with Python
Learn the seven arithmetic operators and understand how they interact with types.
Duration: 50 minutes Skills: Arithmetic Operations with Type Safety (A1-A2), Understanding Type Behavior (A2), AI-Driven Edge Case Exploration (A2)
Lesson 2: Comparison Operators — Asking True/False Questions
Master comparison operators to ask questions about data that return True or False.
Duration: 50 minutes Skills: Boolean Comparisons (A2), Type-Safe Comparisons (A2-B1), Comparison Logic (A2)
Lesson 3: Logical Operators — Combining Conditions
Learn to combine True/False conditions with and, or, and not operators.
Duration: 50 minutes Skills: Boolean Logic (A2-B1), Complex Conditions (B1), Truth Tables and Reasoning (A2)
Lesson 4: Assignment Operators — Updating Variables
Understand assignment operators that update variables in place (+=, -=, *=, /=).
Duration: 45 minutes Skills: Compound Assignment (A2), In-Place Updates (A2), Assignment Patterns (A2-B1)
Lesson 5: Keywords and Capstone — Building a Type-Safe Calculator
Recognize Python's reserved keywords and integrate all four operator types in a capstone calculator project.
Duration: 50 minutes Skills: Keyword Recognition (A1-A2), Operator Integration (A2-B1), Validation-First Programming (A2-B1)
Prerequisites
Before starting this chapter, you should have completed:
- Chapters 1-4: AI-Native development mindset (Nine Pillars, AI as learning partner)
- Chapters 5-11: AI tool literacy (Claude Code, Gemini CLI, prompting, context engineering)
- Chapter 12: Python UV package manager (installation and environment setup)
- Chapter 13: Introduction to Python (What is Python + Installing Python + Hello World)
- Chapter 14: Data Types (variables, type hints, int, float, str, bool, None)
What's Next
After completing this chapter, you'll be ready for:
- Chapter 16: Strings and Type Casting (string methods, formatting, conversion)
- Chapter 17: Control Flow and Loops (if/else, while, for - using operators you learned here!)
- Chapter 18: Lists and Tuples (sequences that use operators for indexing and slicing)
Total Time: 4-4.5 hours across 5 lessons
Key Insight: Operators are the verbs of programming. In Chapter 14, you learned the nouns (data types). Now you learn the verbs (operators). In Chapter 17, you'll combine them into sentences (control flow).