Lesson 2

Learning about Functions


In programming, there are times where you may need to write the same lines of code multiple times throughout, and other times where your code may get really messy and difficult to understand.

To help with these problems, we can use functions in our programming.

A function is a block of code that we can use and reuse in our programs. They take many different functions and combine them under a single name.

Functions in python always have a set of parentheses after them, like this() functions can have parameters inside the parentheses, that will change how the function works.

We actually have some functions in our programs already, pensize(), color(), and speed() are all functions that take our input as parameters.

Functions are used to clean up your main program to make it look neater, and so programmers do not need to repeat blocks of code

On line 9 we will be defining a new function. Add the code def vshape():

def begins the definition of the new function

vshape() is the name of the function