The purpose of a function is to have a reference to a specific block of code. That way you can run a long chunk of code by referring back to it without having to copy and paste it again and again. It also enhances readability by laying out specific sections for specific tasks that must be performed many times or even just once.