AP CSP Day 14 - Libraries and APIs
AP CSP Day 14 - Libraries and APIs
Course Information
- Course: AP Computer Science Principles
- Unit: Big Idea 1 - Creative Development (CRD)
- Lesson: Day 14 (50 minutes)
- Learning Objective: CRD-1.N - Use libraries and APIs appropriately
Learning Objectives
Primary Goals
Students will be able to:
- Understand the concept of libraries and APIs in programming
- Use libraries and APIs effectively in programs
- Test and refine program logic involving libraries and APIs
- Analyze real-world scenarios that require libraries and APIs
AP Exam Alignment
- Big Idea 1: Creative Development (10-13% of AP Exam)
- Essential Knowledge: CRD-1.N.1, CRD-1.N.2, CRD-1.N.3
- Computational Thinking Practice: 1.A - Investigate the situation, context, or task
Lesson Structure (50 minutes)
Opening Hook (10 minutes)
1.1 Welcome & Lesson Preview (5 minutes)
Teacher Activities:
- Recap previous day's content on function design and documentation
- Introduce today's topic on libraries and APIs
Student Activities:
- Think about: "What are some examples where we use libraries and APIs in daily life?"
1.2 Library and API Examples Challenge (5 minutes)
Activity: "Identify the Library or API"
Instructions:
- Groups of 4-6 students
- Identify libraries and APIs in given scenarios
- Discuss the importance of libraries and APIs
Purpose: Activate thinking about libraries and APIs
Core Content Instruction (20 minutes)
2.1 What are Libraries and APIs? (10 minutes)
Definition (CRD-1.N.1):
Libraries and APIs provide pre-written code that can be reused in programs.
Key Concepts:
- Libraries: Collections of functions and classes
- APIs: Interfaces for interacting with external services
- Importing: Using libraries in programs
Case Study: Using a library in a simple program
- Program: Generate random numbers
- Library usage: import random; random.randint(1, 100)
2.2 Types of Libraries and APIs (5 minutes)
Examples:
- Standard libraries: math, datetime
- Third-party libraries: requests, numpy
- Web APIs: Google Maps API, Twitter API
Discussion Questions:
- What makes good library and API usage?
- Can you think of an example where libraries and APIs are used in daily life?
- Why are libraries and APIs important in programming?
2.3 Advanced Library and API Usage (5 minutes)
Why is it important?:
- Efficiency: Reduces development time
- Functionality: Adds advanced features
Discussion Questions:
- How can we make efficient use of libraries and APIs?
- Why is functionality important when using libraries and APIs?
Hands-On Activity (15 minutes)
3.1 Group Project: Create a Program with Libraries and APIs (15 minutes)
Activity: "Design a Program"
Instructions:
- Groups of 3-4 students
- Design a program that uses libraries and APIs
- Test the program for correctness
- Present the program to the class
Materials:
- **Program design worksheet
- **Library and API usage checklist
Learning Goals:
- **Understand libraries and APIs
- **Create programs using libraries and APIs
- **Test program logic involving libraries and APIs
- **Present ideas effectively
Assessment:
- **Group participation
- **Program quality
- **Testing thoroughness
- **Presentation clarity
Closure & Preview (5 minutes)
4.1 Key Concepts Review (2 minutes)
Today's Learning Highlights:
- ✅ Understanding the concept of libraries and APIs in programming
- ✅ Using libraries and APIs effectively in programs
- ✅ Testing and refining program logic involving libraries and APIs
- ✅ Analyzing real-world scenarios that require libraries and APIs
AP Exam Connection:
- These concepts will appear in AP exam multiple choice questions
- Understanding libraries and APIs is crucial for the Create Performance Task
4.2 Next Class Preview (3 minutes)
Day 15 Topic: "Program Development with Functions"
- Learning Objective: CRD-1.O - Develop programs using functions
- Activity: Practicing program development with functions
- Homework: Think about a recent program you used. What libraries and APIs did it employ?