7CREATING MODULES TO REUSE YOUR CODE

image

As your programs become more sophisticated, you might want to reuse code you’ve already written to save time. Fortunately, you can reuse your code as a module, which is a program that contains functions that other programs can call.

In this chapter, you’ll learn how to create custom functions and your own module. The turtles will need to run these functions in Chapter 8, so you’ll write functions your tree farmer turtles (and the turtles you make in later chapters) will load as a module.

CREATING FUNCTIONS WITH THE FUNCTION STATEMENT

To create your own functions, you use a function statement, which is made ...

Get Coding with Minecraft now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.