Functions
- Functions are chunks of code all wrapped up into one "word". These take one or more arguments. The function takes these arguments, works its magic under the hood, and returns some value. For example, the sqrt function takes the square root of some number.
- Note that the functions are case sensitive, and the arguments go in parentheses. If there are multiple arguments, they are separated by commas. Some other functions include sum, mean and range. You can pass variables as arguments, and you can even nest functions.
- Practice using the sum, mean and range functions. Examples are shown below. You can practice by typing the following into the console and clicking run: sum(4, 3) mean(1:200) range(10,-4, sqrt(16),5)
- Then, you should see the following in the console.