programming techniques Flashcards

1
Q

sequence

A

set of program instructions are written and exceted in the order that they are written in

e,g
name = input(“please enter name: “)
print(“ shush” +name “.”)

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

branching(selection)

A

allows a program to run sequences if code depending if the condition evaluates to true of false

carried out with if/else and switch/case

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

iteration

A

section of code is repeated using a loop
can be controlled with a condition at the start or end of loop

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

features of iteration

A

count controlled:
definite iteration which is a for loop

condition controlled: indefinite iteration which is a while loop(loops till condition is met)

pre check checks condition before executing statements
pro check executes the statement and then checks the condition

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

recursion

A

when a function calls itself from within the function

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

benefits and drawbacks of recursion

A

benefit:
more natural to read
faster to write as less lines of code
suited for certain problems e,g trees
can reduce size of problem with each call

drawbacks:
Requires more memory than the equivalent iterative algorithm
More difficult to trace as each frame on the stack has its own set of variables
Usually slower than iterative methods due to maintainence of the stack
Can run out of stack memory due to too many calls causing it to crash

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

global variables

A

can be accessed throughout the program
they are declared or set outside any subprograms and subroutines

dangerous as it is easy to overlook themwhen they are changed
make debuggin hard

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

drawbacks of global variables

A

Global variables make it difficult to integrate modules
they increase complexity of a program
they may cause conflicts with names written in other modules
makes debuggin harder

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

local variables

A

are set or declared within a function or a subprogram
can only be accessed from with that subprogram
can be used as a parameter

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

IDE

A

set of tools to develop a program

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

Features of IDE

A

Error diagnostics - can locate and report errors
Code can be examined as it is running which allows logical errors to be pinpointed
Debugging tools allow inspection of variable values this can allow run-time detection of errors

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

IDE - Breakpoints

A

Use to test the program works up to specific points
Check variable contents at specific points
Can set a point where the program stops running

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

IDE - stepping

A

Can set the program to run line by line
Slow down/watch execution
Find the point where an error occurs

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

modularity

A

programs are written in separate sections as it is easier to test

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

functions

A

are subprograms which can return a value but not always

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

procedures

A

perform opeartions but do not reurn values

17
Q

parameters

A

variables that usually have brackets
can be passed by value or by reference

by value:(default)
a copy is made in the subprogram,so changing the value in the subprogram does not change the original value

by ref:
address of the variable is passed to the subprogram
if the variable is changed by the subprogram it stays the same