We're giving Kodable to 100 underserved schools! Donate $1 Learn More

Advanced

Second Grade


Programming concept covered:

Functions, Sequence

Time: 45-55 minutes

Lesson Materials

  • Vocab cards
  • Criss-Cross Applesauce function example image
  • Kodable on-screen: Function Junction, “Functions 101” 4.1-4.5
  • fuzzFamily Fitness graphic organizer
  • Indoor or outdoor space
  • Kodable on-screen (web, desktop, iPad, or Android)
    Available at Kodable.com/download
Download Teaching Materials

Print Lesson Plan

Get a free teacher account

Objectives


  1. Students will be able to define and identify a function.
  2. Students will be able to explain how functions are used in programming.
  3. Students will be able to write their own functions to simplify code.

Vocabulary


  • Sequence: Sequence is one of three basic flow control structures in programming. Also known as order of events, a computer will execute commands exactly in the order or sequence they are written. Commands must be given to a computer in the right sequence, otherwise a program might not run as expected.

  • Function: A function is a sequence of commands that can be reused together later in a program. Functions dictate what code is carried out and allow for separation of code, making it easy to use again later.

  • Program: A set of instructions (given to a computer in code from a programmer) that performs a specific task when carried out by a computer.

  • Algorithm: A set of steps carried out in order to complete a task or solve a problem.

  • Code: The language that programmers use and create to tell computers what to do.

  • Command: Instruction given by a person (programmer) that tells a computer to do something.

Direct Instruction (I do)


Lesson Tip

Download and print the vocab cards to support instruction.

Review: 
Review what a program is, how programs run effectively (sequence), what a programmer does, and how code allows programmers to communicate with computers.

“People are smarter than computers and we need to tell the computer exactly what to do, step by step, to carry out a task. Sequence is the most basic programming concept: the order of the set of instructions programmers give computers to complete a task.”

Introduce:
“Computers often complete the same task more than once and at different times throughout a program. Since we know that programmers have to give instructions to the computer, we know that this means a programmer would have to write the same exact code for the task over and over again. Instead of having to repeat themselves, programmers can store the code that contains the instructions for the computer and name it, so they can easily find and use it again without having to write more of the same code.
Programmers use something called a function to do this. A function is a sequence of commands that can be reused together later in a program. Functions dictate what code is carried out and allow for separation of code, making it easy to use again later. As people, we do this all the time in real life. Think about when we sit Criss-Cross Applesauce.

 We piece together separate steps as one and carry them out in order every time. We don’t have to be reminded or told each step every time we are asked to sit Criss-Cross Applesauce. We learned it in the beginning of the year and we know what to do when we hear the name.

 The name ‘Criss-Cross Applesauce’ is easy for our brains to remember and locate when needed. We can be told to sit Criss- Cross Applesauce 5 times throughout a day or once in the whole week, but we carry out the set of steps at any time and know what it means.”

Think, Pair, Share

“Can you think of another example of a function in real life? What is something with we name that has an ordered set of steps?”

Prompt students as needed. Examples: Kicking in soccer (plant foot, bring leg back, hit ball, follow through) lay up in basketball (run, dribble, jump, release), tying shoes (loop, swoop, pull), making a sandwich (get bread, spread ingredients, assemble bread, cut), various classroom management procedures similar to the Criss-Cross Applesauce example.

 “Programmers don’t like to repeat themselves! Having to write the same code for something they already coded makes the program longer, run slower, and takes up unnecessary time. Functions allow us to repeat a sequence of code without repeating ourselves. This lets us carry out an action with more than one step in just one command.”

Guided Practice

Students will create a workout plan for the fuzzFamily by developing workout functions for each member of the fuzzFamily. Students will use functions to simplify the workout instructions and help the fuzzFamily increase their physical strength.

Activity Materials

  1. fuzzFamily Fitness Handout
  2. Plenty of indoor or outdoor space for exercise and performing athletic movements

Activity 

“The fuzzFamily is rolling across the meadows of Smeeborg when they arrive at a giant hill. Fuzzes are not very strong, and despite their best efforts, the fuzzFamily can’t roll to the top of the hill. Using functions, create a workout plan to help train the fuzzFamily so they can conquer the rolling hills of Smeeborg!”

Hand out the fuzzFamily Fitness graphic organizer and explain students will choose a variety of exercises to write on the lines inside the brackets which contain the function. Each fuzz will have their own set of steps representing a function or a segment of the fuzzFamily workout. Each function needs to be named so that it can be easily called on and reused later in the workout program (see the first function example on the worksheet, blueFuzz). 

Exercises can vary in complexity, depending on how difficult you choose to make each fuzzy function: push-ups, jumping jacks, sit-ups, jumps, hops, etc. Once students have finished crafting workout functions for each fuzz, bring everyone to an area where there is plenty of room for athletic movements.

Practice each function individually, instructing your students to complete blueFuzz function, hollyFuzz function, etc. Guide your students in completing a full workout program by putting some or all of the functions together. Practice calling out each of the different function names and putting them together in different orders (blueFuzz, prismFuzz, rubyFuzz/ rubyFuzz, blueFuzz, prismFuzz) to create different workout programs.

Independent Practice

Students independently practice the concept on their devices by completing Smeeborg Function Junction, "Functions 101" 4.1-4.5.

Exit Ticket: It Fits Where?

Students explain in words and images a connection between the concept and something else they know.

enter your email address and we'll deliver it to you right away!