U5LA1.2: Intro to Functions & Function Calls

What do functions look like in code?

Overview & Teacher Feedback

This lesson will continue to build onto the first lesson on abstraction by beginning to look at what functions look like in code. Students will then focus on identifying function calls and arguments/parameters within functions.
This is more of a direct lesson than the first exploratory one of this unit, so feel free to insert any structures that you think would add play and joy to an otherwise very direct practice.

Objectives

Students will be able to:
  • Identify function calls
  • Identify arguments/parameters in functions
  • Describe the purpose of having arguments/parameters in a given function

Suggested Duration

1 Period (~45 minutes)

NYS Standards

9-12.CT.4 Implement a program using a combination of student-defined and third-party functions to organize the computation.
9-12.CT.5 Modify a function or procedure in a program to perform its computation in a different way over the same inputs, while preserving the result of the overall program.
9-12.DL.1 Type proficiently on a keyboard.
9-12.DL.2 Communicate and work collaboratively with others using digital tools to support individual learning and contribute to the learning of others.

Blueprint Foundations Student Outcomes

  • Abstraction, Generalization and Detail Removal: Component parts are grouped by general characteristics, and unnecessary details filtered out.

Vocabulary

  • Function call: The name of a function, typed when you want to execute the specific steps the function represents
  • Parameters: The values of a function that can be controlled/altered whenever the function is called (inputs)
  • Arguments: Values passed through to a function’s parameters (input values)

Planning Notes

Planning Notes
Materials Needed
This is a practice-heavy, fairly low-lift lesson. Practice can be completed on paper or as a digital worksheet, depending on classroom need and preference.
Practice Worksheet (digital or printed)
Post-Its/Notecards for Exit Slip (optional)

Resources

Assessments

  • Function Call Worksheet (formative)
  • Exit Slip (formative)

Do Now/Warm Up (2-3 Minutes)

Display on board: Yesterday you learned that we can abstract procedures into functions that you can use repeatedly in your code. Based on your learning so far, what do you think a function call is?

Function Calls, Arguments, and Parameters Mini Lesson (~10 min)

Begin by asking students to share answers to the do now, getting as many different answers as possible. Once you’ve heard student ideas, explain that a function call is just what it sounds like: it’s the name we use to call a function, which is a fancy way to say ‘make it happen’ in our program.
Explain that the function call is the name, followed by parentheses, and those parentheses may have some important information inside of them. This diagram can help:
Diagram of an ellipse() function with paramters/arguments/function call labeled.
Explain the important parts of a function and review with an ellipse. Then explain that students will be practicing identifying function calls, parameters, and arguments. Distribute the associated worksheet and fill in the ellipse space as a class.

Function Call Practice Worksheet (10- 15 minutes)

Allow students time to complete the worksheet, either independently or with a partner or small group. One structure that may be useful in this context is Rally Coach (a Kagan Structure) where each partner folds their paper in half, and take turns coaching the other to complete a given problem on their side of the paper. It is important during this that at any given moment, only one person is writing while the other coaches - kind of like pair programming!
While students work, encourage them to get computers and use the reference sheet for anything that they may have forgotten. Circulate and monitor progress as they work.

Return & Review (~10 minutes)

Once the majority of the class has finished, bring them together to review selected answers. It is not necessary to review every function on the page - it can become repetitive - but try to pick a few that are more straightforward, and a few that are more challenging. Additionally, make sure that you speak to at least one function that has no parameters and discuss that this is because the function is intended to run the same way every time as opposed to some of the others which change.
Remind students that next lesson, they will be creating their own functions. Bring their attention to the names of the functions which are all clear, concise, and do exactly what they say. This is best practice when they start writing their functions, as well!
Time permitting, you may want to preview function structure for the next lesson:
Image of an imagined function definition for washHands that takes in amountSoap and time arguments.
Explain that the contents of this function are pseudocode, but the structure is the same as what they will be writing. Ask what they notice and what they are curious about, and use this to both close this lesson and launch the lesson for tomorrow.

Wrap Up

Consider having students write down their thoughts on what they notice about function structure, function calls, parameters, or arguments and using it as an exit slip.

Extensions

There are no extensions for this activity, but if your students move quickly through it, it could be shortened to allow more time for the following, more complex activities.