Software DD (Implementation: Parameter Passing) Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Formal Parameters

A

Formal parameters are the identifiers used to stand for a value that will be passed when a subprogram/method is called:
def CelsiusToFahr(celsius):

From RGC Aberdeen website

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

Actual Parameters

A

Actual parameters are the actual values that is passed into the method/subroutine/function.
Fahrenheit = CelsiusToFahr(78)
or
Fahrenheit = CelsiusToFahr(inputtemp)

From RGC Aberdeen website

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

Global Variable

A

A global variable means it is accessible in EVERY sub-routine of the entire program.
* Python assumes each variable is local if is specified inside a subroutine.
* Python assumes each variable is global if it is specified outside of a subroutine.
This is not a good idea….
* This means EVERY subroutine can change them accidentally.
* The way to counter this is to use local variables.

From RGC Aberdeen website

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

Local Variable

A

Local variables only exist in the subroutine in which they are declared. This is known as the scope of a variable.

For example if there was a variable called counter that was used to control loops and your program had numerous loops then that variables value would change all the time.

From RGC Aberdeen website

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

Advantages of Local Variables

A
  • Aids modularity
    Allows subroutines to be used with their own variables
  • More efficient in terms of memory
    Local variables are disposed of when the subroutine finishes
  • Removes naming clashes with other local variables in other subroutines
    E.g loop counter variables

From RGC Aberdeen website

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

Functions and Subroutines

A

A function returns a value(s) which can be assigned to a variable. Where as a subroutine may not pass out any values.

From RGC Aberdeen website

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