# Functions

A function has brackets after its name and holds statements. It can take values and give one
back with `return`.

```vi
add(a, b):
  return a + b

describe(n):
  if (n > 10):
    return "big"
  return "small"

main try_functions():
  total = add(3, 4)
  print("3 + 4 =", total, "which is", describe(total))
  helper(x):
    return x * 2
  print("doubled:", helper(total))
```

Built-in functions:

| Function | Does |
|---|---|
| `print(a, b, …)` | writes a line to the Output panel (or the console screen) |
| `wait(seconds)` | pauses this function, then carries on |
| `random(1, 7)` | a whole number from 1 up to 6 |
| `go_to(screen)`, `go_back()` | changes screen (lesson **Screens**) |
| `every(seconds, action)`, `stop(timer)` | repeats an action (lesson **Timers and games**) |
| `play(@sound.mp3)`, `stop(sounds)` | plays sounds (lesson **Sound and video**) |
| `visit("https://…")` | opens a web page |
