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:

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

To creating a square procedure as shown below

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

and then calling the square procedure as shown below

1from turtle import *     # use the turtle library
2space = Screen()             # create a turtle screen (space)
3malik = Turtle()             # create a turtle named malik
4square(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