Introduction to methods
Methods are blocks of code that are built to execute specific tasks by the programmer. Methods can be categorized as a form of flow control because they typically do not have to be in a program’s linear order to be executed. There may be cases when the code within a method doesn’t execute at all. One of the benefits of using methods is reuse, where the same lines of code can be executed again by referencing the method, also known as calling the method. This saves time by reducing the time programmers spend writing repetitive lines of code to do the same task by running linear lines of code without it. It also helps reduce the risk of error by having less repetitive code. As we learned in the software engineering process, more code means that there is the possibility for more errors. Unlike loops, where the lines of code run repetitively until the condition is false, the lines of code in a method only run when they are called in the program, so...