A function is a set of code within a program that performs a speciïc task.Functions are powerful programming tools that make programs easier to read and change.The diagonals()function in the following example was written to draw a sequence of three diagonal lines each time it is run inside draw(). (p.39)