U1LA4.2: Intro to Functions and Function Calls

What do functions look like in code?

Teacher Notes and Overview

NB: This lesson technically covers NYS Standard 7-8.CT.4 Write a program using functions or procedures whose names or other documentation convey their purpose within the larger task. However, we know not all schools can guarantee a middle school sequence prior to this course. This lesson can be significantly abbreviated or skipped entirely based on the knowledge your students come in with!

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.

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 and Materials

Resources

Functions, Parameters, and Arguments Practice (Worksheet)

Assessments

Formative:

  • Function Call Worksheet

  • Exit Slip

Summative:

  • Make an Emoji (Mini Project)

  • Abstract Album Art (Final Project)

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:

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 min)

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 or that they have not learned yet. Circulate and monitor progress as they work.

Return and Review (~10 min)

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:

def washHands(brand, time):
    turnOnSink()
    getSoap(brand)
    sudsHand(time)
    rinseHands()
    dryHands()

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 (3 - 5 min)

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.

Last updated