Lecture 9 Flashcards

1
Q

What is a function?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we need functions?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to get a functions to use?

A

built-into Python
Imported modules with functions
User-defined functions
-write your own functions inside your code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly