Chapter 8: Understanding Functions

There are a number of useful concepts that we, as programmers, always should follow. One is to write code that is easy to read and understand. Another is to avoid duplicating code. When you start out your career as a programmer, you will find yourself copying and pasting code and just changing some small things here and there. This is a bad habit as it nullifies the first concept of code that is easy to read because reading more or less the same lines over and over is tedious and it is hard to spot the tiny differences.

A better solution is to package code that we want to reuse several times into a function. A function is a way for us to give a name to a block of code and then, with this name, the code block ...

Get Computer Programming for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.