In computer science, a function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.
As you are a freshman or sophomore in college, you might be familiar with functions in mathematics where you pass an input and you get an output. In programming, functions work in a similar way: you can pass data, known as parameters, into a function, and the function can return data as a result.