Locked lesson.
About this lesson
What are functions and how to use them.
Exercise files
Download this lesson’s related exercise files.
Functions Part 1.docx59.1 KB Functions Part 1 - Solution.docx
59.6 KB
Quick reference
Functions Part 1
A function is like a program inside of your program.
When to use
Use them to break apart your code into reusable parts.
Instructions
To create a function, just name it and pass some parameters:
def namer(first_name):
return ("Hello %s" % first_name)
To run a function, just call it:
print(namer("John"))
Hints & tips
- A function is a program inside of your program
- Functions only run when you call them
Lesson notes are only available for subscribers.