Python for Absolute Beginners Series #4

In this video, I introduce functions.

Functions are similar to a variable in that both assign a value to something.

x = ‘slow and steady wins the race.’

Here x is an example of a variable.

A function is different because it’s a placeholder for an action.

def square():
beeli.forward(100)
beeli.left (90)
beeli.forward (100)
beeli.left(90)
beeli.forward(100)
beeli.left(90)
beeli.forward(100)

square() is the function and is now a placeholder for the action of creating a square.

You no longer have to write out the above line of code every time you want a square, simply code “square().”

Functions help make coding more efficient by decreasing the amount of text you need to type.

Check the video below:

 

 

Leave a comment