Activity

Cooking Code

Overview
Grades 3-8
2 hrs
Topics
Computer ScienceCooking & Baking
Status

In this activity, you’ll follow an algorithm to bake cupcakes, use patterning to decorate those cupcakes, change variables in an algorithm, and design an algorithm for others to follow to recreate cake-decorating patterns.

Did you know that a recipe is a type of an algorithm?  An algorithm is a set of instructions that can be followed to tell someone how to complete a task to get a specific result.  If it is done right, an algorithm is a formula for success.  If your great-grandparent passed down their recipe for falafel or enchilada casserole, you have access to their secrets for creating a delicious meal!


Two cupcake mixes

Frosting

Food coloring

Cupcake liners

Sprinkles or small candy

Eggs (according to package instructions)

Vegetable oil (according to package instructions)

Mixing bowl

Spatula

Oven

Cupcake pan

Paper

Markers or pencils


1
Delicious Algorithms

Food has always been an important part of human life. Food gives our bodies nutrients and energy, but it also gives us something to gather together and celebrate over. Food is an important part of our heritage, with recipes often passed down from generation to generation.

 

Did you know?

Did you know that a recipe is a type of an algorithm?  An algorithm is a set of instructions that can be followed to tell someone how to complete a task to get a specific result. A programming algorithm is a recipe for success in creating code that will produce similar results each time a formula is used.

When different measurements, or variables, are entered, the results may change, but the rules for calculating the answer will always follow the algorithm. Similarly, you might decide to add more chocolate chips to your grandma’s Old Fruit Cake recipe, but the basic ingredients and instructions stay the same.

2
Cupcake Code

You just learned that an algorithm is a set of instructions. In our activity today, you’ll be following a baking algorithm! We’ll base our activity on a standard, boxed cake mix. We’ll follow the algorithm to make the cake, and then we’ll create patterns with frosting and sprinkles.

The company that made the cake got us started already! They combined flour, sugar, baking soda, and a few other cake ingredients together for us. The company also wrote the algorithm to tell us how to make the cake.

1. Review the algorithm.

Read the instructions on the back of the box carefully. What needs to be done first? What would happen if you did things in a different order? What if you skipped a step, like preheating the oven? (You would be changing the algorithm, which might change your results.)

2. Gather your baking supplies.

Gather all of the supplies needed to make cupcakes. Ask an adult for help as needed.

3. Follow your algorithm.

Follow the algorithm (the instructions) to make and bake the cupcakes. When finished, let the cupcakes cool. (You’ll need a few plain cupcakes later on in this activity for your friends or family to test your cupcake-decorating algorithm, so set those aside now!)

4. Gather and prepare decorating supplies.

Gather cake-decorating supplies such as frosting, sprinkles, or small candy. Ask an adult for help if you are using food coloring to tint the frosting.

5. Create a pattern for decorating the cupcakes.

You have a few things to decide about your cupcake decoration!

  • Do you want to color the frosting?
  • Do you want to use one kind of sprinkles or several?
  • Do you plan to make your cupcakes look like the night sky or a bunny’s face?

You get to choose the pattern. Create one pattern for all of your cupcakes or a simple pattern for each cupcake. (Remember, don’t decorate the reserved cupcakes!) The pattern you choose will be your algorithm to help someone else create the same pattern later.

6. Write the algorithm for each pattern.

Using your paper and markers, write an algorithm for each pattern you design. For the example cupcake, your instructions might look something like this.

  1. Frost the cupcake with white icing.
  2. Get yellow and pink sprinkles and sprinkle them on the cupcake.
  3. Get the green clover topper and put it on top.
7. Test the algorithm.

Have a family member or friend try to decorate a cupcake using your written algorithm, without seeing your cupcake. Did the algorithm work?

3
Redesigning

Great work on your cupcake code! If it didn’t turn out exactly the way you wanted, that’s okay.  Now, you’ll have a chance to redesign your cupcake and see how you can make it better!

Did you know?

Boxed cake mixes weren’t always available! Making a cake from scratch is a lot of work, and it can be hard to get right. Companies noticed this and began to sell mixes in the 1930s that helped families make cakes faster and easier.  Some cake mixes would work well with only water! In fact, a lot of our modern cake mixes work with water as the only added ingredient.

The main ingredients in cake are flour, sugar, eggs, fat, and baking soda. Here’s how they work to make cake!

  • Fat: In a cake, fat can mean a few different things. Vegetable oil, canola oil, and butter are all used to add flavor and smoothness to a cake. Using butter makes the cake fluffier and richer because it traps more air in the cake batter when it is beaten.
  • Sugar: Sugar adds sweetness to a cake, but it does more than that! Sugar bonds to the water molecules in the cake batter, making sure the cake stays moist. The bond also helps the cake keep its shape.
  • Flour: The wet ingredients in a cake (the fat and the eggs) combine with the flour to make a protein called gluten. Gluten creates the main structure of a cake.
  • Eggs: Eggs have three jobs in a cake: they make sure all the other ingredients stick together, they help protect the moisture in the cake, and they help the cake hold its shape. When the egg is beaten, it coats the air bubbles and stops them from escaping. This is what makes fluffy pockets of air in cake!
  • Baking Powder: Baking powder is a combination of baking soda and cornstarch. It is an acid that releases air bubbles as the cake bakes. It helps the cake to rise.

When all of these ingredients are combined and heat is added, a delicious chemical reaction happens, turning all the separate ingredients into a yummy cake!

1

Did the algorithm work?  Did your cupcakes turn out well? If not, re-read the instructions carefully. Did you miss something? If it didn’t turn out as well as you would have liked, you can always try again!

2

If you tried baking the cupcakes with just the mix and water, did the cupcakes turn out the same as your first batch?  How did the changes in your algorithm affect the finished product? Which one did you like better?

3

What patterns did you create when you decorated the cupcakes?

4

Were your friends and family able to use your pattern algorithm to recreate your patterns?

5

Were your friends and family able to use your pattern algorithm to recreate your patterns?

6

Did you use numbers or colors to create your patterns?

7

Did you use numbers or colors to create your patterns?

8

Look around you. Where else can you find patterns in your home?

Try using another algorithm in the kitchen. Ask a parent or guardian for their favorite recipe. Can you follow the algorithm to create it?

Try making a variation of the recipe by adding some new ingredients. Did the new ingredients improve the algorithm, or did you like it the old way?

Create your own algorithm by creating a new recipe.  Have your family test it. What did you like? What would you change? Be sure to write down the algorithm and add it to your family recipes!


Cake, technology, science, and business all work together!

  • Data Scientist: A data scientist is a person who helps businesses, including food businesses, to analyze and learn from data. They might help the business use statistics based on sales and feedback to help the business leaders make decisions on products, employment, business locations, and other factors.
  • Machine Learning Software Engineer: Several companies are currently testing the use of machine learning to create delicious recipes. Sometimes the recipes are successful, and sometimes they are not as tasty. Progress is being made on using machine learning and artificial intelligence in the kitchen.

Did you enjoy this activity?

No endorsement by 4-H is implied or intended. 4-H is the youth development program for our nation’s cooperative extension system.