AP CSP Topic 3.14 Guided Notes - Libraries

Big Idea 3: Algorithms and Programming · Topic 3.14 · Guided Notes (Student)

Libraries — Guided Notes

Fill these in during class or catch up here if you were absent. Print this page or work on paper — then check yourself with the CFUs on the Topic 3.14 page.

Print these notesAll CSP topics

Today’s objectives

  • Explain what a software library is, how it simplifies building complex programs, and how existing code comes from internal or external sources (LO AAP-3.D)
  • Explain that an API is a specification for how a library's procedures behave, and use a procedure correctly by reading its documentation (LO AAP-3.D)

Bell ringer

GradeKit is a code library for building gradebook apps. One of its procedures is documented like this — and you have NEVER seen the code inside it: Curve(score, points) → returns score + points, but never more than 100. Using ONLY that one-line description, work out Curve(88, 15) and Curve(70, 5).

Write 2–4 sentences: What are the two results? You just used a procedure without reading a single line of its code — what exactly made that possible? What would have happened if that one-line description had been missing?

01. Libraries and Existing Code

Key Vocabulary (LO AAP-3.D)

Term Definition (write it)
Software library
Existing code segment
External source
API (Application Program Interface)
Documentation

A Library Is Prewritten, Tested Code You Reuse

  • A software library is .
  • The CED says libraries are especially valuable because they .
  • Reusing a tested library procedure instead of rewriting it means .

Where Reused Code Comes From

Internal sources

External sources

  • Reusing a procedure you wrote earlier in the same project is an example of a(n) .
  • A published library you import into your program is a(n) .
  • What internal and external reused code share is that both .

AP TIP: 'Existing code' is not only downloaded libraries — reusing your OWN earlier code counts as an internal source too.

Call It — Don't Rewrite It

GradeKit already provides Average, so you call the procedure instead of writing the averaging loop yourself.

AP Pseudocode (what the exam tests)

scores ← [88, 92, 79]
classAvg ← Average(scores)
DISPLAY(classAvg)

Python (the runnable version)

scores = [88, 92, 79]
classAvg = Average(scores)
print(classAvg)

Output

86

Run and edit this yourself in the coding exercises for this topic.

Stop and think

  1. In two sentences, explain what a software library is and one concrete reason that using one 'simplifies the task of creating complex programs.'
  2. A classmate reuses a validation procedure they wrote for a different project of their own last year. Is that an internal or external source? Justify using the CED's wording.
  3. Name one task in a program where calling a library procedure is clearly better than writing the code yourself, and say why.

Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.14 page.

02. APIs and Documentation

An API Is the Contract, Not the Code

  • An API is a .
  • Knowing a procedure's API means you know what it does but not .
  • The API matters because it lets a programmer .

Documentation Is How You Learn the API

Without documentation

With documentation

  • Two calls that swap argument order, like Passing(70, 65) and Passing(65, 70), show why you must .
  • Without documentation, using a library procedure becomes .
  • Documentation lets a programmer correctly use code that they .

AP TIP: You cannot reliably use a library from its name alone; the documentation is what makes the behavior knowable.

Read the Doc, Predict the Return

Every value below comes ONLY from GradeKit's documented behavior — you never see the code inside. Use the doc to fill in each return.

Complete the empty cells.

Call What the GradeKit doc specifies Returns
Average([80, 90, 100]) returns the average, rounded down to a whole number
Highest([12, 45, 7]) returns the largest number in the list 45
Passing(65, 70) returns true if score ≥ cutoff, else false false
Passing(70, 65) same procedure — arguments are in the order (score, cutoff)
Curve(96, 9) returns score + points, but never more than 100

Watch out — “I Can Just Guess How to Call It”

Myth: If I know a library procedure's name, I can figure out how to call it and what it returns without reading any documentation.

Explain why this is wrong:

Stop and think

  1. In your own words, explain the difference between an API (the specification) and the actual code inside a library procedure.
  2. You are handed Curve(score, points): 'returns score + points, but never above 100.' Predict Curve(96, 9), and explain how you knew without seeing the code.
  3. Explain why the CED describes documentation as NECESSARY — what specifically can go wrong if you call a library procedure without it?

Answer in complete sentences. Then check yourself with the matching CFUs on the Topic 3.14 page.

Common AP Traps

Three ways Topic 3.14 loses points on the exam — one minute now, real points in May.

An API is a specification, not the code — in your own words:

'Existing code' includes your OWN earlier code — in your own words:

Documentation is necessary, not optional — in your own words:

Libraries, in One Slide

  • A software library is a set of reusable procedures you call to help build new programs; using libraries simplifies creating complex programs.
  • Reused 'existing code' comes from internal sources — your own or your team's earlier code — or external sources like published libraries.
  • An API is a specification for how a library's procedures behave and can be used — the contract, not the hidden code inside.
  • Documentation is necessary to understand a library's behaviors and how to use them correctly.

Exit check — I can…

  • ☐  explain what a software library is and how reusing it simplifies building complex programs (LO AAP-3.D)
  • ☐  distinguish internal from external sources of existing, reusable code (LO AAP-3.D)
  • ☐  explain that an API is a specification for how a library's procedures behave and can be used (LO AAP-3.D)
  • ☐  use a library procedure correctly by reading its documentation, without seeing its code (LO AAP-3.D)

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]