Coding Activity: "Fashionable Functions" Mission No. 5

Let's talk about Functions! Functions are a block of code made up of a set of steps that results in a single specific action. In this Coding Activity, you will learn with functions and be able to style your fuzz however you like. Get the activity worksheet here and watch the short video below!

Functions are important because they help your code insert a number of steps under one action, keep your code short, and save you programming time.

A programmer will give this action a simple name so the set of steps can be easily repeated and reused again and again in your program.

Here's your mission: Decorate and Design a new fuzz to join our fuzzFamily using functions in your instructions.

You use functions when you get ready in the morning! Think about the tasks in your morning routine. Maybe you

  1. Take a shower
  2. Get Dressed
  3. Eat Breakfast
  4. Brush your Teeth

All of these actions are made up of a sequence of smaller tasks. For example, there are multiple things you do when you get dressed, like choose your outfit → underwear → clothes → outerwear → accessories → shoes. Since you probably go through these steps in the same order every day, it's easier to think of them all together as one action with one name like "get dressed". Same with the rest of your morning tasks. When you take a set of steps that you use a lot and give it a simple name, you are able to create, use, and learn with functions!

Let's take a deeper look at how a programmer creates and uses a function.

Step 1: define the function.

This means deciding what sequence of steps you want to happen each time the function is used. Take a moment to think about the steps you follow when you get dressed in the morning. Which clothes do you put on first? How many items do you wear? Do you put on any accessories, like hats, necklaces, or glasses? Write out at least 5 steps.

Step 2: Use the function!

In code, this means "calling" the function by simply typing out its name "get_dressed". In your everyday life, "calling" the function just happens in your head when you decide - "ok, it's time to get dressed!"

Did you know the Kodable Fuzzes learn with functions too?!

Only the sequence of steps in the get_dressed function for a fuzz won't be the same as yours. Your mission today is to build a fuzz and define the steps for its get_dressed function just like you did for your own! Get creative! there are tons of different items and accessories to choose from.

Let's walk through this together in Kodable's Fuzz Builder, here...

Click the Build button and give your new fuzz a name. 

Now, notice how there are two functions already in our code. Remember, a function is a block of code that results in a specific action. I see the first action is to set up Fuzz, and the second action is to getDressed! First, I will code the steps in the setupFuzz function by choosing a body, eyes, and mouth. 

Now it's time to write the getDressed function! Take a look back at the number of steps in the function you just wrote for yourself. Then, select the same number of items and hats as you build your fuzz! So if I added 5 steps to my function, I will add 5 items or hats to my fuzz's as well! Remember, the steps inside a function will always run in sequence, so the item in your first line of code will be added to the fuzz first, with the following items layered on top in order.

Once you've completed the get_dressed function and coded the rest of the fuzz, you can use this new fuzz as for your character in the game! Switch between all the fuzzes you build to give them each a spin around the universe. 

Now it's your turn to learn with functions! Create a fun fuzz of our own design with the getDressed() function

Use the function worksheet to practice coding by going over how you get dressed.

Activity Worksheet

Here's your mission: Write out the get_dressed(); a function that describes your morning routine. Then, build a fuzz in Kodable and create a get_dressed function with the same number of steps as yours! Get learning with functions with your fuzz!

Good luck!

Once you finish this Mission, check out our Previous Coding Missions!

Coding Mission 4

Coding Mission 3