6.5. 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.

Similar to the example above, make a procedure that takes in 2 parameters: a turtle and size. The procedure should draw a pentagon. Write the main code to call the pentagon function once.

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

Show Comments

Note

Discuss topics in this section with classmates.

Show Comments
You have attempted 1 of 5 activities on this page