Skip to content
Computer Science · Grade 10

Active learning ideas

Introduction to Libraries and APIs

Active exploration helps students move from abstract concepts to concrete understanding. When students interact directly with libraries and APIs through hands-on tasks, they see firsthand how these tools extend their programming capabilities without requiring full internal knowledge. This approach builds confidence by demonstrating real-world reuse before deeper technical study.

Ontario Curriculum ExpectationsCS.HS.P.4CS.HS.P.5
30–45 minPairs → Whole Class4 activities

Activity 01

Jigsaw30 min · Pairs

Library Scavenger Hunt: Math Module Exploration

Pairs receive a list of math library functions and incomplete code snippets. They consult documentation to match functions like sqrt or factorial, then test and modify code to solve problems such as calculating circle areas. Groups share one unique discovery with the class.

Explain how libraries and APIs promote code reuse and efficiency.

Facilitation TipDuring Library Scavenger Hunt, circulate but avoid giving answers—redirect students to the math module documentation when they ask for help.

What to look forProvide students with a simple API documentation snippet (e.g., a weather API endpoint). Ask them to identify the base URL, one available function, and the expected format of a request parameter. Then, ask them to write one sentence explaining why using this API is more efficient than trying to collect the data themselves.

UnderstandAnalyzeEvaluateRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 02

Jigsaw45 min · Small Groups

API Data Fetch Challenge

Small groups use the requests library to call a free API like JSONPlaceholder for user data. They parse the JSON response, display key fields, and handle errors like invalid endpoints. Extend by adding user input for custom queries.

Analyze the documentation of a simple API to understand its functionality.

Facilitation TipFor API Data Fetch Challenge, model one successful call yourself before letting students try, then troubleshoot their errors together.

What to look forPresent students with a short Python code snippet that imports and uses a library function (e.g., `math.sqrt()`). Ask them to identify: 1. The library being used. 2. The specific function being called. 3. What the function is expected to do. 4. What the output might be for a given input (e.g., `math.sqrt(25)`).

UnderstandAnalyzeEvaluateRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 03

Jigsaw35 min · Individual

Program Builder: Random Data Generator

Individuals import random and datetime libraries to create a script generating fake datasets, such as sales records. They read docs to chain functions like choice and randint, then output formatted results to console or file.

Construct a program that utilizes an external library to perform a specific task.

Facilitation TipIn Program Builder, pair students so one writes the code while the other verifies each library function’s purpose in the docs.

What to look forPose the question: 'Imagine you need to add a feature to your program that sends an email. What are the advantages of using an existing email library compared to writing the email sending code yourself from scratch?' Facilitate a brief class discussion, guiding students to articulate concepts of code reuse, efficiency, and reliability.

UnderstandAnalyzeEvaluateRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 04

Jigsaw40 min · Small Groups

Documentation Relay: API Breakdown

Teams divide an API doc page; each member summarizes one section (endpoints, auth, examples). They relay info to reconstruct a full usage guide, then code a sample call collaboratively.

Explain how libraries and APIs promote code reuse and efficiency.

What to look forProvide students with a simple API documentation snippet (e.g., a weather API endpoint). Ask them to identify the base URL, one available function, and the expected format of a request parameter. Then, ask them to write one sentence explaining why using this API is more efficient than trying to collect the data themselves.

UnderstandAnalyzeEvaluateRelationship SkillsSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Teach documentation as the primary tool for using libraries and APIs, not the source code itself. Avoid overwhelming students with low-level details early; focus instead on how to read function signatures and return values. Research shows that students learn reuse best when they experience immediate success with small, verifiable tasks rather than abstract explanations.

By the end of these activities, students will confidently import libraries, call functions, and make API requests without hesitation. They will articulate how documentation guides their use of external code and recognize when to rely on these tools versus writing original code. Successful learning shows in their ability to debug small issues and explain their design choices.


Watch Out for These Misconceptions

  • During Library Scavenger Hunt, watch for students who believe they must understand the entire math module’s source code to use its functions.

    Pause the activity and model reading the documentation aloud as a group. Have students highlight the function signatures and examples they actually need, then practice calling just those functions in small tests.

  • During API Data Fetch Challenge, watch for students who assume APIs will always return valid data without issues.

    Inject intentional errors into the API response during the challenge. Guide students to write try-except blocks around their requests, then discuss how to handle different status codes like 404 or 503.

  • During Program Builder: Random Data Generator, watch for students who dismiss the library as ‘cheating’ and refuse to use it for original logic.

    Hold a whole-class code review where students present their programs. Focus the discussion on how the library functions enabled their unique features, such as generating random questions for a quiz app.


Methods used in this brief