Pen block idea: Parameterized functions

Edited

You can use the Pen blocks to explore the idea of parameterized functions, too.

Notice the Length and Size parameters for our new Draw Square function. You can drag these parameters into the function definition code blocks—we set pen size to Pen Width and now move Square Length pixels. Then when we call the function, we specify how big we want the square to be, and how wide the pen should be too.

Give it a try! Call your new function several times, each time changing the parameter values, so the function draws a different sized square. This is a cool and powerful way to code!

Note: You can add parameters as you Create a function. But you can double-click the function parameter (or click the pen icon 🖊) to add new parameters to an existing function, too.