Page 40 - Touchcode_C8_Flipbook
P. 40
3 FUNCTIONS IN DEPTH
Learning Outcomes
Introduction Functions at a Glance
Function Parameters Returning Value from a Function
INTRODUCTION
Pattern is a series of things that are repeated in sequence. In the same way, there is a pattern
in code too. When you do programming, there are times when you want the computer to
repeat certain lines of code in sequence.
If there is a block of code that you want your computer to repeat lots of times, the tool that
you may want to use is a function.
In this chapter, you will going to learn how to create and use functions in block coding, and
return value from functions.
FUNCTIONS AT A GLANCE
A function is a block of code which is made up of a set of steps that result in a single specific
action. The programmer will give a simple name to this specific function, as giving a simple
name to a function increases the chances that the set of steps can be easily reused again
and again in the program.
Advantages of using Functions
Functions gives the program a modular structure and reduces the complexity of the
program.
All the functions in a program can be individually tested.
Functions help the programmers to avoid rewriting the same logic again and again.
Functions make a code reusable, as they can just be copied from one program and used
in another by making required modifications, making them versatile.
38 Touchcode-VIII

