Lecture 9 Flashcards
What is a function?
A function is a block of organized, reusable code that together performs a specific task.
A function runs only when it is called.
Virtually all programming languages used today support functions.
Why do we need functions?
Reusability
-The major reason to have functions
-Functions are important for reusing code:
Modularity
-Functions allow complex processes to be broken up into smaller steps.
-Too long code makes it is hard to read and maintain
-A good and attentive developer divides the code (or more accurately: the problem)into well-isolated pieces and encodes each of them in the form of a function.
How to get a functions to use?
built-into Python
Imported modules with functions
User-defined functions
-write your own functions inside your code