IFB104 Lecture Notes - Lecture 3: Computer Language, Integration Testing, Global Variable
Document Summary
Topic 3 - how to create reusable code. Functions and modules are the standard mechanisms for making reusable code. Functions: a function is a named, parameterised sequence of statements. We can refer to a function by its name to invoke or call it. The statements forming the function"s body determine what it does. The parameters allow us to customise the function"s behaviour when we call it. Functions give us a way of structuring large programs: most programs are broken down into several distinct functions (at least, the non-trivial ones are, packaging groups of related functions into importable modules extends our computer language. Functions must be defined before they can be called. Example of defining and calling a function: a function definition introduces a new function with a name, optional parameters and a body. "def" assigns the function a definition command, then the name follows it.