SDD : Computational constructs Flashcards
Global Variables
Global variables - accessed by every sub-program or module at all times. Always present in RAM during execution
Local Variables
Local variables - only accessed within the sub-program that they have been declared/created within. Only present in RAM during the execution of the sub-program where they are located
Disadvantages of gobal variables
Subroutines can change the variables by accident
Adavtages of local variables
More effecient in terms of memory
Removes naming clashes with other local variables in other subroutines
Actual parameters
Passes in to subroutines
Formal parametres
def addnumber ( FORMAL PARAMETRES)
Subprograms/routines
A sub-program is a block of code that can be called and accessed by a main program
Functions
are sub-programs designed to return value(s) which can be assigned to a variable
Procedures
Procedures are sub-programs designed to perform a series of commands with values sometimes passed to another part of the program
Converting character to ASCII
ord(“a)
converting ascii to character
chr(“a)
converting floating point numbers to substrings
original=24.54
int(original)
Substrings
[start:stop:step}