From the course: Introduction to Career Skills in Software Development

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Functions in Python

Functions in Python

- [Instructor] DRY is a core principle of software development that stands for don't repeat yourself. Programmers attempt to write simple, easy to read, and unrepetitive code. Functions help us do this. A function is a block of code grouped together with a name. They are a core feature of all programming languages. You've already used a function, print, to show something on the screen. There are hundreds of other functions in Python we've yet to explore. To better understand how functions work, let's create one. The first step is to use the def statement. Def is short for define. This keyword let's Python know we want to create our own function and define what it is. So we'll type def and then space. Next, we need to give our function a unique name. We're going to name it Say Hello. Like variables, we can name a function anything that we like as long as we stick to the programming language's syntax. The next thing we…

Contents