Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
Text values
15. Functions


Perfect! It's time to move on to something more advanced: using functions.

A function is a logical chunk of code that performs a specific task and returns a value that can be further used in code. When we use a function, we say the function has been called or invoked. Let's see an example of this in action:


Here, round is the name of the function that is being called. The parentheses surround the argument of the function. In this case, the argument is 14.35. While this particular version of the round function accepts a single argument, other functions can accept more arguments, and some don't take any arguments.

The function round does just what its name suggests: it rounds a decimal number to the nearest integer. In our example, the function will return 14.


In one of our previous exercises, we calculated John's ideal body weight to be 84.2 kilograms. Round this decimal number to the nearest integer.