From the course: CompTIA PenTest (PT0-002) Cert Prep

Unlock this course with a free trial

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

Procedures and functions

Procedures and functions

- As a last topic that we want to cover, how do I write code that is reusable and is as compact as possible? New developers, script or any type of software developers, have a tendency to write line by line linear code so that you just have to go through hundreds of lines of code to figure out what happens. As you learn more about coding techniques, it's very common to take any functionality that you want to execute more than one time and put it into a code block. So you could just refer to it and say, go do that, Go do that again, go do that a third time without having to have those lines of code in your program or script over and over again. So we have two different constructs called functions and procedures that we use to do exactly that. So let's go look at some Python examples on the subtle differences between functions and procedures and why you might use them. Let's look at procedures. Here, we're going to go to easypythondocs.com and look at their entry for procedures. An easy…

Contents