Functions Flashcards

1
Q

Function

A

A named block of statements that can be called within a program

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

Purpose of functions

A

Enable reuse of code
Allow for code modularity
Help write more complex programs

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

Parameters

A

Allow variation in function behaviour

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

Formal Parameters

A

List of parameters in its definition

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

Actual parameters/arguments

A

Whenever the function is called a value must be provided for each of the formal parameters

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

Pass-By-Value

A

Only a copy of the value of a parameter is sent to a function
So if there is an original variable, it cannot be changed by the function changing the parameter

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

Local variable

A

New variables can be created and used within functions but they disappear when the function ends

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

Global variable

A

Global variables can be accessed but not changed

Use the global statement to allow changes to global variable

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