Skip to main content
AP CSP course

F17 · Topic 3.14

Library contract clinic

Evaluate two fixed text-library implementations against a precise contract, then propose a replacement and compatibility tests.

1. Predict first

Predict normalise(" A B ") under the documented trim/lowercase/preserve-internal-spaces contract.

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 1 A B Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try internal double spaces, only spaces and non-ASCII letters.

2. Build your procedure

Write pseudocode for a wrapper that normalises a label, then displays it. Document what it returns, and choose two compatibility tests.

Use AP CSP pseudocode, a language you know, or precise plain language. Your code is not executed here. Use the classroom assignment to save your response.

3. Check boundaries

Public worked tests for the fixed model
InputExpectedWhy this case
" RED Bus ""red bus"Trim ends and change ASCII case.
"A B""a b"Keep internal whitespace.
" """All end spaces are removed.

4. Explain and reflect

Why is collapsing internal spaces an observable contract change?

Model limits: Only the documented fictional text functions run. This is not a package installer or a general code executor.

Teacher guidance and scoring