AP CSP CodeX - Functions with Parameters Lesson 2
Functions with Parameters Lesson 2
Students add parameters to functions in three programs, then review when to use parameters and local variables.
Overview
Students work on computers in the CodeSpace Sandbox. This lesson is not part of a mission. Students add parameters to functions in three programs they have already written: Answer_Bot (Unit 2 Mission 8), Heart2_functions (Unit 2 Mission 6), and Display_functions (Unit 1 Mission 4). They then review when to use a parameter and when to use a local variable, and complete the questions on the Activity Guide.
🎯 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.
- A parameter can be any data type, including a bitmap image, a string, a button, Boolean, etc.
Assessment Opportunities
- Functions with Parameters Lesson 2 Activity Guide
- Answer_Bot_parameters program
- Heart2_parameters program
- Display_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 2 slides
- ▸Functions with Parameters Lesson 2 Activity Guide
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- Make sure students can open their Answer_Bot_functions, Heart2_functions, and Display_functions programs in the CodeSpace Sandbox. Students who need the original code can use the most recent final version of each program from the class dashboard.
- Prepare the Activity Guide to give to students. It is used for notes during the lesson and for the review at the end.
- If you have a word wall, or another form of vocabulary presentation, prepare the terms.
- Students complete this lesson on the computer, using the Sandbox in CodeSpace for programming. This lesson is not part of a mission.
- Students add parameters to functions in three programs. The best experience will come 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.
- The most recent final version of each program can be found in the class dashboard. The programs come from these missions:
- Answer_Bot: Mission 8 (Unit 2)
- Heart2_functions: Mission 6 (Unit 2)
- Display_functions: Mission 4 (Unit 1)
- Solution code for all finished programs is provided.
- Follow the slides for instructions and guidance.
Lesson Outline
This outline gives one way to present the lesson.
Review functions with students.
- Slide 2: Students write three or more things they know about parameters and arguments in their Activity Guide. You can have them do a think-pair-share, etc.
- Slides 3-4: Review when to use parameters and procedural abstraction.
💻 Students work at computers for this lesson. They use the Answer_Bot_functions program from Unit 2 Mission 8.
💻 Students use the Heart2_functions program from Unit 2 Mission 6.
💻 Students use the Display_functions program from Unit 1 Mission 4.
💻 Students do not use the computer for this activity.
✅ 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 parameters
- Exit ticket