Parameters, Return, and Libraries - Lesson 4: Parameters and Return Make

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.

Goals

Students will be able to:

  • Write functions with parameters and return values that meet a set of specified requirements
  • Debug programs that use functions with parameters and return

Purpose

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.

Resources

Supplemental Code.org material

Getting Started (5 minutes)

Prompt: How do parameters and return change the way you write programs?

Discuss: Have students share their ideas with a partner and then discuss as a class.

Discussion Goal

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

Teaching Tip

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
  • 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.

Lesson4_ExampleApp - Explore: Have students explore the working Rock Paper Scissors app. If students are not working in pairs they should still discuss the prompts 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.

Distribute: Give students copies of CSP Parameters and Return Make - Rock Paper Scissors App (Activity Guide) if you will be using it during the lesson.

Submit: Encourage students to check the rubric below or on the last page of the Activity Guide before submitting.

Rubric for assessing student projects
CategoryExtensive EvidenceConvincing EvidenceLimited EvidenceNo Evidence
findIcon FunctionThe function returns the correct values for all input values.The function returns the correct values for most input values.The function returns the correct values for some input values.The function does not return correct values for any input values.
randomChoose FunctionThe function returns the correct values for all input values.The function returns the correct values for most input values.The function returns the correct values for some input values.The function does not return correct values for any input values.
decideWinner FunctionThe function returns the correct values for all combinations of inputs.The function returns the correct values for most combinations of inputs.The function returns the correct values for some combination of inputs.The function does not return correct values for any combination of inputs
Code runs without errors.No errors are present in the required code.Some errors are present in the required code.Many errors are present in the required code.The code does not run.
Coding CommentsComments are used to correctly explain the purpose and functionality of all functions.Comments are used to explain the purpose and functionality of most functions.Comments are present, but are not used to explain the purpose or functionality of any functions.Comments are not present.

Wrap Up (5 minutes)

Prompt: How could using parameters and return help you write programs collaboratively?

Discussion Goal

Goal: This prompt 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.

Standards Alignment

  • CSTA K-12 Computer Science Standards (2017): 2-AP-14
  • CSP2021: CRD-2.F.7

Next Tutorial

In the next tutorial, we will discuss Code.Org Unit 7 Lesson 5, which describes Learn about libraries.