(this is all assumed to be done in the shell)
Before we start, we need to get into our Python shell. Once you open up your terminal program of choice, you'll want to type python
. You should now see some information about the version of Python you're running and three greater-than symbols. If you have IPython installed, feel free to use that instead.
In programming, a "function" or "method" is often the name we give to blocks of code that the computer can repeat for us. In our human world, this would be like us going through the same sets of folds for all of the napkins at a wedding reception.
In Python, these stand-alone, repeatable code blocks are called "functions" and we create new ones with the def
keyword. Function names have to start with an underscore or a letter and can't contain spaces or hyphens. We'll call this function "hello". Function definitions always end with an open parenthesis. We'll talk about passing arguments to functions