From the course: Learning Python

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Python functions

Python functions - Python Tutorial

From the course: Learning Python

Python functions

- [Instructor] Most applications, regardless of the programming language that they are written in, are broken up into smaller blocks known as functions. And Python's no different. Functions give us a way of organizing our programs so that they are more understandable and modular. In this example, we're going to take a look at how functions work in Python. So in my editor, I'm going to open up the functions_start file. And we're going to start off by defining a function. So functions are defined with the def keyword, along with a name. So I'll name my function func1. And then I'll use open and close parentheses. Now this function doesn't take any arguments, but we'll get to that in a little bit. And next comes a colon character. The colon indicates that you're starting the scope or body of a function. In other languages like Java and C, for example, use curly braces for this, but Python uses the colon and then white…

Contents