Problem solving/programming Flashcards
1
Q
subroutine benefits
A
easier to read
- there are fewer long blocks of code to understand
more efficient
- blocks of code can be used once and re-written many times
more reliable
- each subroutine can be individually tested to make sure it works
2
Q
parametres
A
- special variables used to pass values into a subroutine
3
Q
arguments
A
- the actual values that are passed in
- (through the parameter)
4
Q
local variable
A
- a variable defined within a subroutine
- has a local scope
- can only be accessed within that subroutine
5
Q
global variable
A
- variable can be made global by adding the ‘global’ keyword before it when first used
- may be accessed by any part of the whole program
6
Q
passing By Reference
A
- function receives memory location of the data
- will make changes to the original variable
- will overwrite data in the original variable
- will keep the changes after the function ends
7
Q
passing By Value
A
- function receives a COPY of the variable
- will not overwrite the data in the original variable
- will not keep the changes after the function ends
8
Q
global benefits over local
A
- don’t need to return a value
- can be accessed from anywhere in the program
- variable doesn’t need passing as a parameter
9
Q
global drawbacks over local
A
- increases memory usage (held in memory until full program execution is over)
10
Q
benefits of using reusable components
A
- reduced testing requirements
- saves time from having to write the same algorithm repeatedly