AP CSP CodeX - Functions with Parameters Lesson 1
Functions with Parameters Lesson 1
Students add parameters to functions in two programs they have already written, and learn how parameters, arguments, and local variables work.
Overview
Functions have been used in almost all programs beginning with Mission 3, but they do not require a parameter until Mission 9. This lesson builds on that foundation. Students revisit programs they have already written and add parameters to functions and arguments to function calls. Students work at the computer in CodeSpace, modifying two programs. The lesson also goes over local variables.
🎯 Mission Goal: Students learn about parameters, arguments, and local variables.
Learning Targets
- I can identify a parameter and what it is used for.
- I can identify a local variable and what it is used for.
- I can determine when to use a parameter and local variable.
- I can use parameters in functions.
- I can use arguments in function calls.
Key Concepts
- A parameter is used in a function when it needs information from the main program to complete a task.
- Using a parameter with a function is a form of procedural abstraction because the details of how the function accomplishes a task are hidden.
- Local variables are defined inside a function and can only be used in the function.
Assessment Opportunities
- Functions with Parameters Lesson 1 Activity Guide
- pixels1_parameters program
- billboard_parameters program
Success Criteria
- Identify parameters in a function definition and state what they are used for
- Identify local variables in a function definition and state what they are used for
- Use parameters in a function
- Use arguments in a function call
Digital Resources
- ▸Functions with Parameters Lesson 1 slides
- ▸Functions with Parameters Lesson 1 Activity Guide
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Real-World Applications
Extensions & Cross-Curricular
x is the parameter, and in f(5) the value 5 is the argument. Students evaluate f for several arguments.
🔤
Vocabulary
▾
🐍
New Python Code
▾
def game(message, button):Function definition with parameter.
game("Press B", BTN_B)Function call with argument.
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- Students modify their own programs from earlier lessons: Pixels1_RGB (RGB Colors Lesson, Unit 1) and Billboard_functions (Mission 7 Obj 7-9, Unit 2). Make sure students can find both programs in CodeSpace.
- If a student does not have a program, the most recent final version of each one is in the class dashboard, so all students can start in the same place.
- Review the slides, which give the instructions and guidance for the lesson.
- This lesson is completed on the computer, using the Sandbox in CodeSpace for programming. It is not part of a mission.
- Students add parameters to functions in the Pixels1_RGB and Billboard_functions programs.
- The best experience comes from students modifying their own code. However, we want all students to be engaged, so you can give them the original code to modify if needed.
- Solution code for both finished programs is in the class dashboard.
- Follow the slides for instructions and guidance.
Lesson Outline
Follow the slides for instructions and guidance. Students work at computers in the CodeSpace Sandbox.
Review functions with students.
💻 Students will work at computers for this lesson. They will use the Pixels1_RGB program from the Unit 1 RGB Colors lesson.
Students will use the Billboard_functions program from Unit 2 Mission 7.
✅ The activity guide and two programs are complete and ready to turn in.
Formative assessment:
- Check for Understanding at the end of the Activity Guide
- Daily reflection journal or Google Form
- Class discussion on what they learned about functions with parameters
- Exit ticket