Module 05
Teach ManoNew Skills
Functions let us give a group of instructions a name. Once Mano learns a skill, we can ask her to use it whenever we need it.
Watch
Meet Python Functions
Watch the short lesson, then use the interactive activity below to follow Python as it calls a function.
The Big Idea
Write once. Use many times.
Imagine Mano needs to move forward many times. Instead of repeatedly writing the same instructions, we can package them into one function.
Define
Use def to teach Python a new function.
Name
Give the skill a meaningful name such as move_forward.
Call
Use move_forward() whenever Mano needs that skill.
Interactive Learning
Follow the function
Step through the program and watch how Python moves from the main program into the function and then returns.
Output
Teach Mano a new skill
The def keyword creates a function. We are teaching Mano a skill called move_forward.
Give Functions Information
Functions can useparameters.
Mano does not always need to move the same distance. A parameter lets us give the function information when we call it.
Your Mission
Teach Mano to turn left.
Create a function called turn_left() that prints "Turning left". Then call the function twice.
You've completed Module 05
