Lesson 24: Functions with Parameters in Bee

Overview

This lesson features the bee environment, and continues along the concept of functions with parameters from the previous Artist stage. Students will practice writing and using functions to follow complex paths and collect patterns of nectar and honey.

Purpose

Functions are incredibly important in computer science for many reasons. The ability to break down and categorize code will become immensely important as the programs your students write become more and more complex. Functions with parameters require an extra level of skill. Using functions with parameters teaches your students to recognize when a function is needed and if that function can be generalized enough to be used for multiple cases. This lesson, along with the previous lessons on functions with parameters, builds a strong set of critical thinking and problem solving skills.

Agenda

Warm Up (15 min)

Main Activity (30 min)

Wrap Up (15 min)

View on Code Studio

Objectives

Students will be able to:

  • Recognize repeated tasks that need to be specialized on a case-by-case basis and create functions to efficiently run these tasks.
  • Use pre-built functions with parameters to complete commonly repeated tasks.

Preparation

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

For the Students

Vocabulary

  • Function - A piece of code that you can easily call over and over again.
  • Parameter - An extra piece of information passed to a function to customize it for a specific need

Support

Report a Bug

Teaching Guide

Warm Up (15 min)

Introduction

Before class, set up a couple of paths in the classroom for students to walk on. Make sure the number of steps is obvious either using tape or cut outs of footprints. These paths should vary in length.

Gather the class together and note that there are different paths to walk down, but you don't want to have to write separate functions to walk down each one.

Instead, on an display the class can see, write or display the following

FUNCTION - "path", PARAMETER - "step"

  • repeat "step" times:
    • walk forward

Ask the class if they know what the code you wrote means. Tell the class that instead of writing a unique function for each path, you wrote a function that can be customized to the length of the path.

This was done by declaring a function, "path", then giving it a parameter, "step". The variable, "step", can be used to hold the number of steps for each path.

Play with the function for each path, having a volunteer name the number of steps in a path and another volunteer walking down the path according to the code.

Main Activity (30 min)

Course F Online Puzzles - 2018 - Website

As the class works through these puzzles walk around and ask the following questions to each student.

  • Are you using a function? Why or why not?
  • If you aren't using a function, do you think a function could be helpful here?
  • If you are using a function, are you using a parameter? Why or why not?
  • If you aren't using a parameter do you think a parameter could be helpful here? Why or why not?

Sometimes the students won't need to use a function or a function with parameters, but they should always know why they are doing what they are doing.

Wrap Up (15 min)

Journaling

Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.

Journal Prompts:

  • What was today’s lesson about?
  • How did you feel during today’s lesson?
  • Do you think parameters are helpful in code?
  • When did you use a parameter and how did it change the way you wrote the rest of your program?

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 1B-AP-08 - Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
  • 1B-AP-09 - Create programs that use variables to store and modify data.
  • 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.

Cross-curricular Opportunities

This list represents opportunities in this lesson to support standards in other content areas.

Common Core English Language Arts Standards

L - Language
  • 5.L.6 - Acquire and use accurately grade-appropriate general academic and domain-specific words and phrases, including those that signal contrast, addition, and other logical relationships (e.g., however, although, nevertheless, similarly, moreover, in addition).
SL - Speaking & Listening
  • 5.SL.1 - Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 5 topics and texts, building on others’ ideas and expressing their own clearly.
  • 5.SL.1.a - Come to discussions prepared, having read or studied required material; explicitly draw on that preparation and other information known about the topic to explore ideas under discussion.
  • 5.SL.4 - Report on a topic or text or present an opinion, sequencing ideas logically and using appropriate facts and relevant, descriptive details to support main ideas or themes; speak clearly at an understandable pace.
  • 5.SL.6 - Adapt speech to a variety of contexts and tasks, using formal English when appropriate to task and situation.

Common Core Math Standards

MP - Math Practices
  • MP.1 - Make sense of problems and persevere in solving them
  • MP.2 - Reason abstractly and quantitatively
  • MP.3 - Construct viable arguments and critique the reasoning of others
  • MP.6 - Attend to precision
  • MP.7 - Look for and make use of structure
  • MP.8 - Look for and express regularity in repeated reasoning

Next Generation Science Standards

ETS - Engineering in the Sciences
ETS1 - Engineering Design
  • 3-5-ETS1-1 - Define a simple design problem reflecting a need or a want that includes specified criteria for success and constraints on materials, time, or cost.