teacher note Teachers Note: Creating Procedures with Parameters

You probably don’t quite feel comfortable with creating procedures with parameters right now. That’s okay. Our research on how people learn programming says that understanding how names can represent something else takes alot of practice. People new to programming will probably prefer:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from turtle import *
space = Screen()
malik = Turtle()
malik.forward(100)
malik.right(90)
malik.forward(100)
malik.right(90)
malik.forward(100)
malik.right(90)
malik.forward(100)
malik.right(90)

To creating a square procedure as shown below

1
2
3
4
5
6
7
8
9
def square(turtle,size):
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)
    turtle.right(90)

and then calling the square procedure as shown below

1
2
3
4
from turtle import *     # use the turtle library
space = Screen()             # create a turtle screen (space)
malik = Turtle()             # create a turtle named malik
square(malik, 100)           # draw a square with side length 100

When people are first learning programming, they prefer seeing actual values like forward(100) over forward(size). They can probably recognize that having one square function that can make squares of all kinds of sizes is flexible and thus powerful. But, they are still trying to understand the baisc turtle commands yet.

Don’t worry about creating procedures with parameters yet. That will come later in the chapter on abstraction. Abstraction means focusing on just the important details in a context, just like using an abstract figure to identify female restrooms as shown below.

abstract representation of a female

Figure 2: Abstract representation of a female

Right now, it’s okay to just be able to read procedures and understand what happens when they are called. As beginners become more comfortable with basic programming, they will be ready to use the abstraction of using names to represent things like new procedures and functions.

You have attempted of activities on this page