Video Coming Soon...

Created by Zed A. Shaw Updated 2024-12-10 18:57:40
 

18: Names, Variables, Code, Functions

Big title, right? I am about to introduce you to the function! Dum dum dah! Every programmer will go on and on about functions and all the different ideas about how they work and what they do, but I will give you the simplest explanation you can use right now.

Functions do three things:

  1. They name pieces of code the way variables name strings and numbers.
  2. They take arguments the way Python scripts take argv in Exercise 13.
  3. Using 1 and 2, they let you make your own "mini-scripts" or "tiny commands."

You can create an empty function by using the word def in Python like this:

View Source file ex18_demo.py Only

Back to Module Next Lesson

Register for Learn Python the Hard Way, 5th Edition (2023-2024)

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.