Teaching functions


#1

How do you teach the core computer concept of functions to your students?

Share your best practices, hacks, tips and tricks here. Also feel free to share here your questions, half-baked ideas, spectacular failures and concerns about teaching loops.

In your post, be sure to tell us what grade you teach and any other relevant information about your classroom context that will help other understand how they might implement your idea.


#2

Here are a few code.org Code Studio resources for teaching functions:

Unplugged Lesson Plans

Review “Functional Suncatchers” Lesson Plan: Course 3

Code Studio Activities

Explore Course 3 functions stages:


#3

In math we use functions all the time. If my students are advanced enough I might discuss the steps it takes to do a long division problem. Or I could do something simpler and talk about a lunch line and the function of each kitchen staffs’ job.


#4

I agree with Eric. We use the word function throughout our building in math class. Fortunately, our students have been exposed to this word before and therefore the concept is not as difficult for them to understand. I skipped the sun-catcher unplugged activity when working through this course with my students. However, if the concept and vocabulary was new to my students I would more than likely first work through this lesson.


#5

I might try to connect functions to the current fad of making rainbow bracelets. Different patterns of bracelets each have their respective function. Or, connecting it to LEGO building where functions may be defined and used throughout the process of building a more complex structure. Functions in playing chess may be another interesting way to talk about this topic - for example, a ‘fork’ and a ‘pin.’


#6

Functions are more than loops because they can include, not only loops, but all sorts of other commands to include , exclude, or determine.


#7

I really liked being able to pull the chorus with the Little Bunny Foo Foo song and calling it as a function. I could also use the song “There was an Old Lady who Swallowed a Fly.” We could call a function for each animal in the song.

I also was thinking of revisiting the playground and writing instructions to move around the playground (I am going to use this for sequences as well) but then having them call functions to get on the playground equipment.


#8

Functions are an interesting concept. It was easiest when I explained it like a copy of art you already created. If you draw a circle, you can continue to “copy” that circle and use it again when you need it. Almost like a stencil or die cut.


#9

I would like to try introducing functions in the gym. I love the way Chris Bosh explained how in basketball you learn the basics, like how to dribble and pass the ball, then use those skills in different ways and give them a name so everyone on the team knows how/what to do. Students could work in teams to come up with and name their own ‘skills,’ then teach those skills and their name to other teams. At some point students discuss the fact that they are creating functions. A student calls out a function name like ‘jump and jiggle’ and classmates practice that function.


#10

Most of my 7th and 8th grade students have already learned about functions in their math classes. For those who haven’t caught on, yet, I would use a popular (school appropriate) song. The chorus would be the function.


#11

Really when you think about it, any recipe students already know how to make becomes a function.

Take for example, a student that is focused on mining. He knows how to create a pickaxe. He goes off and mines and eventually his pickaxe breaks. He calls the function “Make a new pickaxe” from his memory and goes off to make one. He does not have to relearn how to make it, since he has that function already stored in memory somewhere.


#12

In kindergarten, first, and second grades, I would ask the students to identify tasks they complete in their daily life which have been given a name that everyone in their family or everyone in the classroom can understand. Examples might be: get dressed, brush your teeth, feed the dog, get ready for PE, pack up to go home from school. Each of those tasks is really a series of steps that we have packaged together and given a name to.

I like the idea of the sun catcher project. I think similar projects could be used at different grade levels to reinforce the concept of functions.


#13

While teaching the Course 3 Functional Suncatcher Unplugged lesson last year to a group of fourth grade gifted students, one of them asked me to explain the difference is between a function and an algorithm. We discussed the similarities, but our discussion regarding what makes them different was hazy. I’d love to hear your thoughts.


#14

Your point that everyday tasks are functions - “a series of steps packaged together” - is a great one. Students would really be able to understand that. I’ve had them try to explain how to make a PB&J sandwich before. If they don’t get all the steps, it can be a mess. Same way with a function.


#15

The way I’ve heard it explained is that an algorithm is a set of instructions for a computer to follow, and an algorithm might include a function. Functions are mini-snippets of code you might want to call again and again over many algorithms. Think of it like a “chorus” in a song, that gets “called” after each verse. It’s not quite a loop, but it IS a building block of a program. Not sure if I am 100% correct tho. Anyone else have a better explanation?


#16

I liked the ideas of using the steps for long division and songs for explaining the concept of functions to my adult students.


#17

With 7th and 8th graders, pointing out functions as a way to shorten their code by making their own block helped. Once they made the function for the square and then used the function to draw repeated squares to make a picture, without having to use all of the usual blocks made learning functions a priority.


#18

I like the way of connecting the “chorus” to a function. This helped me and will help my students understand functions.


#19

Mi piacerebbe spiegare il concetto di funzioni ai miei alunni (sia delle scuole elementari che delle medie) utilizzando un pianoforte :musical_keyboard: ed utilizzando delle sequenze di tasti bianchi :white_circle:, tasti neri :black_circle:, pause :zzz:, cluster di note :boom: e battiti di mani :pray:. Utilizzando la tastiera del pianoforte gli alunni avrebbero un’ampia possibilità di utilizzare suoni diversi.
Skill 1: :white_circle: :black_circle: :zzz: :white_circle: :black_circle: :zzz:
Skill 2 :boom: :pray:
Program: Skill 1 Skill 1 Skill 2


#20

I’d say that a function is basically an algorithm with a name.

Going farther, I’d say that we give it a name so that we can tell the computer to do that algorithm using one word, instead of having to type out all of those lines of code every time we want that algorithm to happen.

Going even farther, I’d say that a function can be algorithms within algorithms (or functions within functions). For example: eatBreakfast might be a function that includes the functions setTable, makeToast, and pourCereal, and also algorithms for walking from one part of the kitchen to another, in between those functions.