Lesson 4: Parameters and Return Make
45 minutes
Overview
Students use the knowledge and skills they've developed working with parameters and return values to develop a Rock Paper Scissors App. Unlike typical Make projects, students are given a significant portion of the starter code but are given three functions with parameters and return values that they'll need to develop themselves. At the end students submit their apps which can be assessed using a provided rubric.
Standards
CRD-2 - Developers create and innovate using an iterative design process that is user-focused, that incorporates implementation/feedback cycles, and that leaves ample room for experimentation and risk-taking.
CRD-2.F - Design a program and its user interface.
- CRD-2.F.7 - The design phase of a program may include: ● brainstorming ● planning and storyboarding ● organizing the program into modules and functional components ● creation of diagrams that represent the layouts of the user interface ●
AP - Algorithms & Programming
- 2-AP-14 - Create procedures with parameters to organize code and make it easier to reuse.
Agenda
Objectives
Students will be able to:
- Debug programs that use functions with parameters and return
- Write functions with parameters and return values that meet a set of specified requirements
Preparation
- Review the app students will need to make and ideally spend some time working on the project yourself to anticipate the challenges students will encounter
- Check the "Teacher's Lounge" forum for verified teachers to find additional strategies or resources shared by fellow teachers
- If you are teaching virtually, consider checking our Virtual Lesson Modifications
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the teachers
For the students
- CSP Parameters and Return Make - Rock Paper Scissors App - Activity Guide
Teaching Guide
Warm Up (5 minutes)
Discuss: How do parameters and return change the way you write programs?
Have students share their ideas with a partner and then discuss as a class.
Discussion Goal: This discussion should prompt students to better understand what turns out to be a slightly different make project. Today they're going to be taking on "blank functions" rather than "blank screens". This is because with parameters and return values you can chunk out your programs into pieces that have well-defined behavior. Remind students that this is known as procedural abstraction. If students don't land on these ideas don't aim to force it but return to this idea in the wrap up.
Remarks
Today we're going to be working on another Make project, but this one is a little bit different than others we've done in the course. A lot of the code will already be written for us, and we'll be working on blank functions, rather than entirely blank programs. Thanks to the way that parameters and return work, it's easy to design programs this way.
Activity (35 minutes)
Build the Rock Paper Scissors App
Supporting Students: While students are working on their apps, circulate the room and check in with students who need a little help. Encourage students to collaborate and discuss bugs with each other.
Debugging: Review with students steps they can use to debug if they get stuck:
- Build small parts of the program at a time and test them to make sure they work
- Run the code on turtle mode
- Add the variables to the watcher
- Explain the code to a friend and clarify the differences between what they expect to happen and what is actually happening in
Group: Make a determination as to whether this project will be completed in pairs or individually. You may even choose to let students decide.
Level 1 - Explore: Have students explore the working Rock Paper Scissors app in Level 1. If students are not working in pairs they should still discuss with a neighbor.
- What does each button do
- How does the screen get updated after clicking each button
Review: Quickly review what students will be doing again before they move on to the next step.
Make lessons typically ask students to take on an entirely blank screen when writing their program. In this instance students have to take on the "blank function" which needs to fit within the larger program they're developing. This is part of a broader mindset shift that students develop in this unit. Functions with parameters and return values operate like their own "mini programs" which can be written and tested independently. There is actually less difference than students might think between previous make projects, in which students get the user interface elements and no code, and this project, in which they get some starter code but blank functions with parameters. In each case they need to develop programs that integrate into a larger portion of the project. The focus of this unit is how functions with parameters and return values help further split programs into logical chunks like this.
Distribute: Give students copies of CSP Parameters and Return Make - Rock Paper Scissors App if you will be using it during the class.
Do This: Direct students to level two where they complete the Rock Paper Scissors App. Based on the needs of your classroom decide whether you will collectively go through the activity guide or have students complete it individually. Afterwards give them time to work on their projects and circulate the room to offer support. Students who finish early can work on the extensions suggested in the activity guide.
Submit: Encourage students to check the rubric on the last page of the Activity Guide before submitting.
Adapting Make Lessons - You may decide that you'd like to have your students write the code for a modified or entirely different app using the same skills. This might help you differentiate your instruction or provide you with a way to reassess students. Check out the Customize Make Lessons: How-To-Guide for guidance on how to get started with this.
Wrap Up (5 minutes)
Discuss: How could using parameters and return help you write programs collaboratively?
Discussion Goal: This should help review ideas that students saw in this project, in particuarly that parameters and return help break programs into chunks. It should also help them see that this approach could be used to collaboratively design programs. If teammates agree in advance what each function should do they can go off and write them separately before coming back together to make the entire app work.
Remarks
Parameters and return help us chunk programs into pieces. Each important piece can be made into its own function which can be written and tested separately from the others. If you and your partner agree in advance how to split up the way a program is written and are clear on what each function needs to do, you could develop a program just like this make project.
Assessment: Grading the Project
Rubric: Use the rubric provided with the project to assess student projects.
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.