Programming techniques (2.2.1) Flashcards

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

What are the three main programming constructs?

A
  • Sequence
  • Selection
  • Iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is sequence?

A

Code is execute line by line from top to bottom

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

What is selection?

A

A specific block of code is run if a specific condition is met, using IF statements.

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

What is iteration?

A

A block of code is executed a set number of times or while/until a condition is met using FOR, WHILE or REPEAT UNTIL loops.

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

What is the scope of a variable?

A

It refers to the section of code where the variable is available.

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

What are the two main variable scopes?

A
  • Local

- Global

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

What is a local variable?

A

A variable that can only be accessed in the block of code in which they are defined.

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

Local variable ADVS

A

Ensures subroutines are self-contained i.e. the variable are not affected by code outside of the subroutine

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

What is a global variable?

A

Can be accessed throughout the whole program.

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

Global variable ADVS

A

Useful for values that need to be used by multiple parts of the program

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

Global variable DISADVS

A
  • Can be unintentionally overwritten.

- Require more memory than local variables

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

What is modular programming?

A

A technique used to split large, complex programs into smaller, self-contained modules.

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

Modular programming ADVS

A
  • Makes problems easier to understand and approach
  • Can divide tasks between a team
  • Simplifies testing and maintenance, can deal with each component individually
  • Code is reusable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Modular programming DISADVS

A
  • Can cause complexity in simple programs

- May be challenging to keep track of function names and values

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

What are functions and procedures?

A

Blocks of codes that perform a specific task

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

What is the difference between a function and a procedure?

A

A function returns a value, a procedure doesn’t

17
Q

What are parameters?

A

Values that are passed into a function

18
Q

What are the two methods that can be used to pass parameters?

A
  • By value

- By reference

19
Q

What is passing by value?

A

The parameter is effectively treated as a local variable:

-A copy of the variable is copied to the parameter meaning changes made do not effect the value elsewhere.

20
Q

What is passing by reference?

A

The address of the parameter is given to the subroutine so the value will be updated at the address giving a permanent change.

21
Q

What is an IDE?

A

An Integrated Development Environment is piece of software which provides a set of tools making it easier to write, develop and debug code.

22
Q

Examples of IDEs

A

IDLE, Microsoft Visual Studio, Pycharm, Eclipse

23
Q

Common IDE features

A
  • Stepping
  • Variable watch
  • Breakpoint
  • Source code editor
  • Debugging tools
24
Q

What is stepping in an IDE?

A

Allows the user to monitor the effect of each line of code by executing one line at a time.

25
Q

What is variable watch in an IDE?

A

Used to observe the changes of variable contents in real time

26
Q

What is breakpoint in an IDE?

A

Allows to set a point where the program will stop (based on a condition or a specific line), this helps to pinpoint errors.

27
Q

What features does a source code editor provide in an IDE?

A
  • Autocompletion
  • Indentation
  • Syntax highlighting
  • Bracket completion