Unit 02

Selection and Iteration

Build Magpie — a chatbot that reads what a person typed and answers it — and in doing so learn the two things that turn a list of instructions into a program that responds to the world: decisions, and repetition.

25–35% of the AP Exam~29–31 CED periods~15–17 blocks here12 topics

AP Computer Science A · members' unit

Selection and Iteration is behind a locked door

Units in AP Computer Science A are for people taking the course. Getting in takes a link or a key — signing in on its own doesn't do it.

What's in this unit · 32 min read

  1. The project · Magpie
  2. 2.1 · Algorithms with selection and repetition
  3. 2.2 · Boolean expressions
  4. 2.3 · if statements
  5. 2.4 · Nested if statements
  6. 2.5 · Compound Boolean expressions
  7. 2.6 · Comparing Boolean expressions
  8. 2.7 · while loops
  9. 2.8 · for loops
  10. 2.9 · Implementing selection and iteration algorithms
  11. 2.10 · Implementing String algorithms
  12. 2.11 · Nested iteration
  13. 2.12 · Informal run-time analysis
  14. Finishing Magpie
  15. Where this goes next

29 quick checksstepperloop tracerchatbot sandboxtruth tablescode exercises+1 more

1 Sign in

With your school Google account. This is how your work reaches the gradebook — it doesn't open the unit by itself.

2 Get in

Open the class link your teacher posted — that's the usual way, and it enrols you on the spot. Or paste an access key if you were handed one.

A key unlocks this browser and keeps your progress here; signing in keeps it with you across devices. Either way the key itself is only ever checked as a hash. Manage all of this on your account, read what signing in stores, or go back to AP Computer Science A.

Sources

  • College BoardAP Computer Science A Course and Exam Description, Effective Fall 2025
  • Gilmour AcademyCourse structure and standards adaptation
  • Laurie WhiteMagpie Lab (AP Computer Science A lab series)