Functions help you to make your code shorter and easier to debug. That saves time and effort. They are blocks of code that you can use just by giving the name of that function. In effect you are creating your own new commands.
The code used in this video can be found at https://lyw4.life/Resources/python.php.