Lesson 3: Parameters and Return Practice


Students practice writing programs with parameters and return values by creating and debugging functions that use them.


This is students' opportunity to practice using parameters and return values in a variety of contexts. The progression of levels builds in complexity from students merely calling functions with parameters to designing functions and debugging complex programs that use parameters and return values. This lesson should build students familiarity with these concepts as they prepare for the Make project in the next lesson.


Lesson Modifications

Warm Up (5 mins)

Activity (35 mins)

Wrap Up (5 mins)

View on Code Studio


Students will be able to:

  • Correctly set up a parameter in a function
  • Correctly set up a return value in a function
  • Write comments to explain the function purpose, parameters, and return values


  • Review the programming levels students will complete


Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

Teaching Guide

Lesson Modifications

Attention, teachers! If you are teaching virtually or in a socially-distanced classroom, please read the full lesson plan below, then click here to access the modifications.

Warm Up (5 mins)

Quick Warm Up

Discussion Goal

Goal: Use this quick prompt to review what students should already have seen about parameters and return values while also prompting them to think about how they'll need to use those skills in today's lessons. You should use your remarks to review the fact that parameters and return help write neater programs, but they may be a little tricky at first to read and understand. That's why we practice!

Up to this point, students have only seen complete traversals - that is, traversals where every element of a list is accessed. Now that they've been introduced to return, students can build partial traversals where a list is only partially accessed. For example: A list could be traversed to find a specific element. Once that element is found, "found element x" is returned, and the traversal stops. While students don't actually need to build partial traversals themselves, they now should know how it theoretically could be created.

Prompt: What is one reason why parameters and return values are useful? What is one way you think programming with parameters and return values may make programming or debugging more challenging?

Discuss: Have students share responses with a neighbor before discussing with the whole class.


Parameters and return values allow us to write code that is neater and works in a larger number of scenarios. We're going to have to practice reading, writing, and debugging code like this however, because it works a little a differently than the programs we've gotten used to writing. Let's dive in!

Activity (35 mins)

Practice Time

Group: It is recommended that students work in pairs for this lesson.


Today you're mostly going to practice what we've learned about programming with parameters and return values. In general we want to use the debugging process we've practiced all year, but here's some specific things to look out for in today's lesson.

  • Use console.log to call functions with parameters with different values to see how they run
  • Slow down the code with the speed slider to see how the code is running once your function is called

Teaching Tip

Providing Support: Circulate around the room through the lesson encouraging students to use the strategies introduced at the beginning of the lesson. Students have a number of supports at their fingertips, so a big part of your role is helping build their independence in using those resources.

Levels 2-6: These levels involve functions with parameters and return values, working in the console

  • Level 2: Calling a function multiple times with a single parameter
  • Level 3: Students follow a pattern to choose a randomCompliment from a list that is concatenated with a name passed through a parameter.
  • Level 4: This is the same as Level 2, except now the functions use return values. Again, students follow a pattern given in another working function.
  • Level 5: Students write a function that returns the season a month is in. By this point, students should be noticing the type of commenting that is happening above each function. This format previews how students will need to write comments for libraries later on in the unit.
  • Level 6: This level traverses lists to find the longest and shortest words. Parameters and return values are used.

Levels 7-8: Students continue practicing, now working with apps

  • Level 7: Students debug and comment an ordering app. Completing this level will require students to read programs that use functions with parameters and return carefully.
  • Level 8: We return to the compliment code, this time reworking it into an app. Again students write their own comments, this time including comments for a return value. Students also complete the updateScreen function, which calls both of the functions with parameters.

Level 9: Students do a quick practice with the MOD operator.

Extension Opportunities:

  • Level 8: Add more greeting and compliment options to the lists

Wrap Up (5 mins)

Discussion Goal

Goal: Use this opportunity to address any lingering questions or misconceptions in the room. You can also use this as a source of discussion topics to kick off the following lesson. As you lead the discussion, call out the many resources students have access to help when they're getting stuck.

Prompt: What aspects of working with parameters and return values do you feel like clicked today? What do you still feel like you have trouble with?

Discuss: Have students share with one another before sharing with the whole class.


Working with parameters and return values can be tricky. We will get more practice tomorrow by making an app that uses lists to store information.

Assessment: Check For Understanding

Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.

Question: The procedure below will be called twice with two numbers provided as arguments to the parameter myNumber. Which of the following pair of numbers will mystery return the same value?

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 2-AP-14 - Create procedures with parameters to organize code and make it easier to reuse.


AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.C - Evaluate expressions that use arithmetic operators.
  • AAP-2.C.2 - The exam reference sheet provides a MOD b, which evaluates to the remainder when a is divided by b. Assume that a is an integer greater than or equal to 0 and b is an integer greater than 0. For example, 17 MOD 5 evaluates to 2.
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
  • AAP-2.O.1 - Traversing a list can be a complete traversal, where all elements in the list are accessed, or a partial traversal, where only a portion of elements are accessed. EXCLUSION STATEMENT (EK AAP-2.O.1): Traversing multiple lists at the same time using the sam
AAP-3 - Programmers break down problems into smaller and more manageable pieces
AAP-3.A - For procedure calls: a. Write statements to call procedures. b. Determine the result or effect of a procedure call.`
  • AAP-3.A.5 - The exam reference sheet provides procName (arg1, arg2, …) as a way to call PROCEDURE procName(parameter1, parameter 2, …) which takes zero or more arguments; arg1 is assigned to parameter1, arg2 is assigned to parameter2, and so on.
  • AAP-3.A.7 - The exam reference sheet provides the RETURN(expression) statement, which is used to return the flow of control to the point where the procedure was called and to return the value of expression.
  • AAP-3.A.8 - The exam reference sheet provides result ß procName(arg1, arg2, …) to assign to result the “value of the procedure” being returned by calling PROCEDURE procName(parameter1, parameter2, …)
AAP-3.C - Develop procedural abstractions to manage complexity in a program by writing procedures.
  • AAP-3.C.1 - The exam reference sheet provides PROCEDURE procName(parameter1, parameter2, …){<block of statements>}which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements.
  • AAP-3.C.2 - The exam reference sheet providesPROCEDURE procName(parameter1, parameter2, …){ <block of statements> RETURN(expression)}which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements and returns th