Naming Sets of Procedures and Functions¶
So far we’ve seen names for values, like variables that hold strings and numbers. We’ve also seen how to name (define) functions or procedures and use additional names to store the inputs to those functions or procedures.
Sometimes, you will want to have have a whole group of functions and/or procedures, and you will want to store them somewhere and name that whole set of functions and procedures. In fact, you can. And in fact, you have already used this ability.
That is what you are doing when you execute a statement like from turtle import *
. That is where the procedures like forward
and right
and functions like Screen
are defined. We can mix procedures and functions that we define with procedures and functions that we import.
- square
- You can use square since you just defined it, but you can also use the others.
- forward
- You can use forward because of the import, but you can also use others.
- right
- You can use right because of the import, but you can also use others.
- All of the above
- Yes, you can use all of the turtle stuff from the import, plus the procedure square that was defined.
csp-6-9-2: Imagine that you add one more line to the program above. Which procedure can you use safely, because it will have been defined?