From the course: Python Quick Start

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Building your own functions

Building your own functions - Python Tutorial

From the course: Python Quick Start

Building your own functions

Built-in functions are powerful, but there will be times when you need to create your own functions to help you complete specific tasks. So in this video, I'm going to show you how to create your own functions and use them. Now, I want to point out the different parts of defining a function. The first part of defining a function is def. def is a keyword that stands for definition. It indicates to the computer that you're defining a function. Next, is the name of the function. Make sure to come up with a name that's relevant to what the function is going to do. Then comes a pair of parentheses, followed by a colon. Now, if your function needs to take input, you should come up with a name to represent the input and place it inside the parentheses. If your function does not need to take input, you should leave the parentheses empty. On the next line, be sure to indent. You can do this by using tab. Now comes the body of your function. The body is where you write out the procedure your…

Contents