All Subjects



AP Comp Sci P



Big Idea 3: Algorithms and Programming


2 min read•november 16, 2020


Minna Chow

AP Computer Science Principles ⌨️

Bookmarked 2.3k • 69 resources
See Units

You don't have to define every procedure you use in a program. If you're using already-written code, you can import it into your program. In Python, you do this by importing the module it's contained in. This importing usually takes the form of a line of text at the top of your program that looks like this:
from location import module
There are several places where already-written modules come from.

API Software Libraries

A software library contains already-developed procedures that you can use in creating your own programs. You don't have to write new procedures to, for example, display images or find derivatives in your program; someone's already written those procedures and put them in a library for the public to use.
There are libraries for everything under the sun. Here are some Python examples:
  • Pillow allows you to work with images.
  • Matplotlib allows you to make 2D graphs and plots.
You can also import some of your own previously written code into a new program.
An Application Program Interface, or API, contains specifications for how the procedures in a library behave and can be used. It allows the imported procedures from the library to interact with the rest of your code.
In order to make the most of both APIs and Libraries, both need to be well documented. Libraries are, at their heart, a collection of other people's code, and it would be difficult to understand how the procedures should be used without documentation. APIs explain how two separate pieces of software interact with each other, and they also need documentation to keep this communication going.

Was this guide helpful?

Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
Hours Logo
Studying with Hours = the ultimate focus mode
Start a free study session
🔍 Are you ready for college apps?
Take this quiz and find out!
Start Quiz
Browse Study Guides By Unit
🕹Big Idea 1: Creative Development
⚙️Big Idea 2: Data
📱Big Idea 3: Algorithms and Programming
🖥Big Idea 4: Computer Systems and Networks
⌨️Big Idea 5: Impact of Computing
📝Exam Prep
Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
💪🏽 Are you ready for the AP CSP exam?
Take this quiz for a progress check on what you’ve learned this year and get a personalized study plan to grab that 5!