The code is PHP code. You can add it to functions.php of your active theme.
If you are using a downloaded theme it is better to create a child theme first and edit that. That way the files will not be overwritten by an update.
Can you manage?