Code Reusability and Organization
Learn about writing functions and comprehensively grasp the concept of top-level programs and functions.
We'll cover the following
Writing functions
A fundamental principle of programming is Don’t Repeat Yourself (DRY). While programming, if you find yourself writing the same statements repeatedly, then turn those statements into a function. Functions are like tiny programs that complete one small task.
For example, we might write a function to calculate sales tax and then reuse that function in many places in a financial application. Like programs, functions usually have inputs and outputs. They are sometimes described as black boxes, where we feed some raw materials in one end, and a manufactured item emerges at the other. Once created and thoroughly debugged and tested, we don’t need to think about how they work.
Get hands-on with 1400+ tech skills courses.