🏆 Project: build the mind reader
Why: Build the mind-reader game from scratch — everything combined.
Unlocks: The confidence that you can BUILD, not just follow.
Remember the mind reader from How Computers Think? The computer guessed your secret number in 7 questions by halving the range each time. Back then you played it. Today you build it — with nothing but the tools you now own: variables, input, if/else, while.
First, the reverse game to warm up — you guess the computer's number:
Read that program slowly — you understand every single line now. That wasn't true when you started this course.
Now the real thing: the mind reader itself. The computer asks “is it bigger than X?” and halves the range — binary search, the algorithm from the recipes lesson. Here it is — read it first, then run it:
(// is whole-number division: 7 // 2 is 3, no fraction. Perfect for splitting ranges.)
Want to push further? Ideas: make it celebrate differently when it wins in 5 questions or fewer; change the range to 1–1000 and count how many questions it needs (the switches lesson told you: ~10).
Why does the mind reader never need more than 7 questions for 1–100?
In the game loop, why is guess = 0 set before the while?
🔍 Go deeper: the loop-within-a-decision pattern you just used, traced step by step → PyDebug: Loops and PyDebug: Decisions.