AP CSP - Python with CodeX - Defining Functions
Defining Functions
Students learn what abstraction and functions are, then define and call functions in their Mission 3 program.
Overview
This lesson introduces functions before they appear in a Mission or CodeTrek. Students first learn what abstraction and functions are. Then they return to the program they created in Mission 3 and define and call functions in it.
🎯 Mission Goal: Students will learn to define and call functions.
Learning Targets
- I can define "abstraction" and "function".
- I can identify places in code where a function can be defined.
- I can define a function that accomplishes a task.
- I can call a function in code.
- I can state benefits for using functions.
Key Concepts
- A function is a form of procedural abstraction. It hides the details of accomplishing the task.
- Abstraction is an integral part of computer science and coding.
- Programmers write functions that accomplish a task.
- A function can be called multiple times and in any order in a program.
- A function must be called before its code is executed.
Assessment Opportunities
- Defining Functions Activity Guide
- Pixels1_functions program
Success Criteria
- Define "abstraction" and "function"
- Correctly define a function
- Understand how and when to call a function
- Define and call one or more functions in a program
- Determine when a function should be used in code
Digital Resources
- ▸Defining Functions slides
- ▸Defining Functions Activity Guide
-
▸Code solution (
Pixels1_functions.txt) and Activity Guide answers: Teacher Dashboard, Educator Resources button
Classroom Materials
- ▸CodeX (one per student or pair)
- ▸USB-C cable
- ▸Computer
Real-World Applications
The process of hiding complex procedures in a system is widespread.
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework - Learning Objectives
AP CSP Framework - Computational Thinking Practices
- Students modify their Mission 3 program, so make sure they can find it in the CodeSpace Sandbox. If a student needs code to start from, have the solution code for Pixels1_final (Mission 3) ready.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms (abstraction and function).
- At the end of the lesson, you will discuss clearing the CodeX before turning it in. Have the Clearing CodeX slides ready.
- Functions are a vital concept for AP CSP, and students should have a lot of practice defining and calling functions. This lesson has students modify the program they created in Mission 3 by defining functions.
- This lesson is completed on the computer, using the Sandbox in CodeSpace for programming. It is not part of a mission.
- Students should do a "Save As" with each program to keep the original code.
- Students will modify a previous program. The best experience will come from them modifying their own code. However, we want all students to be engaged, so you can give them the original code from Mission 3 to modify if needed.
- Follow the slides for instructions and guidance. Solution code for the final program with functions is provided.
- You can add the vocabulary to a word wall and keep a document or chart of the Python code learned during each mission.
Lesson Outline
This outline gives the narration for one way to present the lesson.
This short warm-up introduces abstraction and functions. Students take guided notes on their Activity Guide.
Students work in pairs (or individually) at their computers.
Students work in pairs (or individually) at their computers.
✅ You decide what you want students to turn in for a grade, and how they turn it in: the Activity Guide and/or the Pixels1_functions program. You can look at the code on student computers, or have them submit code. The Activity Guide can also be turned in.
The wrap-up can be very short for this lesson (slides 27-28). This is the class's chance to review abstraction and functions and make their own meaning with the terms.
Formative assessment:
- Daily reflection journal
- Class discussion on what they learned about abstraction and functions
- Activity Guide completion
- Defining and calling functions in Mission 3
- Exit ticket