← Back to Library
Lesson PlanFreeEN

E4: Functions - Part 1

Students will review their previous lesson on Function blocks and explore using Functions in computer programming. They will use Blockly preset programs and Challenge Cards to practice their new skills.

Gr. 4–4
E4: Functions - Part 1

Lesson

Overview

Description

Students will review their previous lesson on Function blocks and explore using Functions in computer programming. They will use Blockly preset programs and Challenge Cards to practice their new skills.

Objectives

  • define a function

  • identify the differences between a function and a loop

  • identify times when a function should be used instead of a loop

  • use functions to revise code and complete coding challenges in an iterative process

Before the Lesson

Prior Experience

It is recommended that students complete:

  • Level A-D Lessons: All

  • Level E: Lesson 1-3

  • [Optional] Level A-D Challenge Cards: All

  • [Optional] Level E Challenge Cards: E 1.1-2.3

You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://store.makewonder.com/#/education

Preparation

  • Fully charge the tablets and robots.

  • Install the Wonder Workshop Blockly app on each tablet.

Review

Functions

  1. Ask, "What is a function?"

    • Sample response: "A function is a piece of code that can be called over and over."

  2. Ask, "How did you use functions in the last lesson?"

    • Sample response: "We used functions to create a song/chant."

  3. Ask, "Why was using functions important in that activity?"

    • Sample response: "Functions enabled us to write a chant/song without having to rewrite the chorus each time it was used."

Code.Org Connections (Optional)

  1. Show Code.org's video about functions: https://studio.code.org/s/course3/stage/9/puzzle/1

  2. After watching the video, ask, "What songs can you think of that have choruses?"

    • Sample response: "Jingle Bells" or "Hokey Pokey"

Direct Instruction

Introduction

  1. Say, "We learned how to use functions in songwriting. Today, we will learn how to use functions in a computer program by studying a Blockly preset program."

  2. Review real-life examples where you would use functions, such as:

    • singing a song chorus

    • doing a routine event, like brushing your teeth

  3. Discuss how students might use functions in their code: "We can use functions to repeat parts of our code over and over again. Unlike loops, we can repeat the function's code in multiple places of our program."

Quick Check

  • How is using functions in a program similar to the chorus of a song? (Sample response: "The chorus of a song repeats multiple times throughout the song. The function in a code can repeat multiple times throughout the program. There are bits of code in between each instance of a function in a program, just like there is other music in between each instance of a chorus in a song.")

  • How do you use functions in your life? (Sample response: "Making different types of sandwiches for a group of friends requires repeating some steps (like a function) while still performing a few different steps for each sandwich, such as using different meats and cheeses.")

Guided Practice

Activity: Yes No Yes

  1. Project your tablet screen, open the Blockly app, and go to the menu at the top left of the screen.

  2. Go to the Create New Project menu and select the Yes No Yes preset program. Then tap "create."

    Yes No Yes
  3. Ask the students to look at the program and predict what they think will happen when it is run.

    • Run the program to see if the students' predictions were correct.

  4. Ask, "How could you change Dash's movements inside the functions?"

    • Sample response: "You can add more drive blocks or change the angles of the look blocks."

  5. Have student volunteers identify where the Call Function blocks are in the program. Then show them where to find the Call Function block in the Start menu.

  6. Say, "Could you run this program using a Repeat block instead of a function? Why or why not?"

    • Sample response: "You could not use a Repeat block since the functions do not repeat consecutively. Repeat blocks can only be used in bits of code that repeat over and over in the same place in the program."

  7. Say, "In Yes No Yes, we used functions to make Dash say 'yes' and 'no.' Think of how you could change the functions for the program so that they make Dash demonstrate two opposite behaviors."

Quick Check

  • How were functions used in this program?

  • Could you have written this program without functions? (Sample response: "Yes, you could have written this program without functions, but the program would have been much longer.")

Independent Practice

Instructions

Have students work on the following activities in small groups (ideally 2-3 students per robot).

Encourage students to share tablet and robot time. Have them establish and rotate through roles such as:

  • Lead Programmer: Holds the tablet and manipulates the code.

  • Robot Wrangler: Retrieves and resets the robot after every program attempt.

  • Documentarian: Records group results, thoughts, and progress. Illustrates group designs and ideas.

When students work together while coding, they're able to help each other identify mistakes and develop creative solutions!

Yes No Yes - Extension

  1. Have students use the Wonder Journal: Dash Planning or General Planning worksheet to design ways to add to or alter the Yes No Yes preset program. They can:

    • Change the name of the functions.

    • Change/add lights, movements, and sounds to each function.

    • Add a loop.

    • Add conditionals by using If or If/Else blocks.

    • Change the order that the functions are called.

  2. After they finish revising the program, have students:

    • Complete a Wonder Journal: Reflection worksheet.

    • Take a screenshot of their Blockly code.

    • Take a video of Dash while the code is running.

Challenge Cards (Optional)

  1. You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://logicsacademy.com/store/

  2. Have students complete the following Challenge Cards:

    • E 3.1: Dance Rehearsal

    • E 3.2: Fancy Wheelwork

    • E 3.3: Dance Off!

  3. For each challenge, encourage students to:

    • Use the Wonder Journal: Dash Planning or General Planning worksheets to discuss how they can complete the challenge.

    • Review the Troubleshooting and Problem Solving & Debugging worksheet if they run into any problems with their code.

  4. After they finish each challenge, have students:

    • Complete a Wonder Journal: Reflection worksheet.

    • Take a screenshot of their Blockly code.

    • Take a video of Dash while the code is running.

    • Update their Challenge Card Checklists.

Wrap Up

Student Presentations

  1. Have student groups take turns sharing one of their programs with the class. Encourage them to:

    • Explain their design thinking (e.g., "We wanted to add (another function) to the program because . . .," or "We changed actions in the function blocks here because . . .").

    • Share any obstacles and difficulties they overcame during the activity (e.g., "At first, we didn't know how to call a function, but then we found the Call Function block in the Start menu").

  2. Encourage students to ask each other how they accomplished different objectives and give each other feedback on their programs. Possible questions/feedback includes:

    • "How did you (program Dash to move like that)?"

    • "I like how you (added another function)."

    • "What if you (changed the order of the Call Function blocks)?"

Follow-Up Questions/Discussion

  • How did the function block help you with your program? (Sample response: "The function block helped me repeat non-consecutive sequences of code.")

  • Could you have written the same program using loops? (Sample response: "No, because loops repeat consecutive lines of code.")

Assessment

  • Use our Evaluation Rubric to review students' work and presentations.

  • [Optional] Share your students' work with the world using @logicsacademy and #dashanddot!

Educational Standards

CSTA

CSTA

  • 1B-AP-10: Create programs that include sequences, events, loops, and conditionals.

  • 1B-AP-12: Modify, mix and incorporate portions of an existing program into one's own work to develop something new or add more advanced features.

  • 1B-AP-16: Take on varying roles, with teacher guidance, when collaborating with peers during the design, implementation, and review of program development.

ISTE

ISTE

  • 4d: Exhibit a tolerance for ambiguity, perseverance, and the capacity to work with open-ended problems.

  • 5a: Formulate problem definitions suited for technology-assisted methods such as data analysis, abstract models and algorithmic thinking in exploring and finding solutions.

  • 6b: Create original works or responsibly repurpose or remix digital resources into new creations.

  • 7c: Contribute constructively to project teams, assuming various roles and responsibilities to work effectively toward a common goal.

NGSS

NGSS

  • 3-5-ETS1-2: At whatever stage, communicating with peers about proposed solutions is an important part of the design process, and shared ideas can lead to improved designs.

  • 3-5-ETS1-3: Tests are often designed to identify failure points or difficulties, which suggest the elements of the design that need to be improved.

Common Core

Common Core

  • CCSS.ELA-LITERACY.W.2.6: With guidance and support from adults, use a variety of digital tools to produce and publish writing, including in collaboration with peers.

  • CCSS.ELA-LITERACY.W.2.8: Recall information from experiences or gather information from provided sources to answer a question.

  • CCSS.ELA-LITERACY.SL.3.1: Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 3 topics and texts, building on others' ideas and expressing their own clearly.

  • CCSS.ELA-LITERACY.SL.3.3: Ask and answer questions about information from a speaker, offering appropriate elaboration and detail.

  • CCSS.ELA-LITERACY.SL.3.4: Report on a topic or text, tell a story, or recount an experience with appropriate facts and relevant, descriptive details, speaking clearly at an understandable pace.

Alberta - Grade 4 - ICT

Grade 4

ICT

C5: Students will use technology to aid collaboration during inquiry.

C6: Students will use technology to investigate and/or solve problems.

F6: Students will demonstrate a basic understanding of the operating skills required in a variety of technologies.

Ontario - Grade 4 - Mathematics

Grade 4

Mathematics: Algebra (Coding)

C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential, concurrent, repeating, and nested events

Nova Scotia - Grade 4 - ICT

Grade 4

ICT

P2: Students will be expected to use digital tools to develop ideas and original works in innovative ways.

TOC1: Students will be expected to 

  • safely use many forms of current technology for learning with growing competence 

  • demonstrate conceptual understanding of how information and communication technology, digital tools, and authorized networks support their learning 

  • use terminology related to information and communication technology

British Columbia - Grade 4 - ADST

Grade 4

ADST

• Make changes and test again, repeating until satisfied with the product 

• Use materials, tools, and technologies in a safe manner, and with an awareness of the safety of others, in both physical and digital environments 

• Identify the skills required for a task and develop those skills as needed 

• Use familiar tools and technologies to extend their capabilities when completing a task 

• Demonstrate a willingness to learn new technologies as needed