Programming Elements Flashcards

1
Q

Identifier

A

A unique name for something (e.g. variable, constant, procedure, etc.) within the program

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

Variable

A

An identifier associated with a specific memory location, used to store data. Its value can change while a program runs

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

Constant

A

A named value within a program with a fixed value that does not change while the program runs

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

What are the benefits of declaring a constant? (2)

A
  1. When its value changes, only the declaration has to be changed
  2. It makes your code easier to read, debug and maintain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why aren’t variable names beginning with underscores encouraged?

A

A considerable number of names beginning with underscores are already reserved for use by the system

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

Data type

A

The type of data stored in a variable

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

What does the data type of a variable define? (3)

A
  1. The type of data stored in a variable
  2. How much memory is needed to store it
  3. The operations that can be performed on it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Integer

A

Data type for whole numbers

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

Real OR Float

A

Data type for fractional numbers

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

Character

A

Data type for a single character

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

String

A

Data type for text (over 1 character). Sometimes limited to a length of 255 characters

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

Boolean

A

A true or false value

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

How much memory is typically needed to store:

  1. An integer?
  2. A float?
  3. A single character?
  4. A boolean?
A
  1. 2 or 4 bytes
  2. 4 or 8 bytes
  3. 1 byte
  4. 1 byte, although 1 bit would suffice
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Assignment

A

When a variable is given a value

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

Initialisation

A

Explicitly setting the starting values of variables

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

Algorithm

A

A series of instructions that solves a specific problem

17
Q

What are the three main parts of program flow control?

A
  1. Sequence
  2. Selection
  3. Iteration
18
Q

Sequence

A

Where instructions are executed one after another in series

19
Q

Selection

A

Where the program executes certain instructions based on a condition

20
Q

The two basic selection constructs are…

A
  1. If/else statements
  2. Case statements*

*Do not exist in Python

21
Q

Boolean expression

A

An expression that evaluates to true or false

22
Q

Logical operators

A

NOT, AND, OR and XOR. Used in conditions and Boolean expressions.

23
Q

Relational operators

A

Operators that compare two values

24
Q

Iteration

A

Where a program executes a group of instructions zero or more times based on a condition

25
Q

What are the three types of iteration loop constructs?

A
  1. While
  2. Repeat/until*
  3. For

*Do not exist in Python

26
Q

How many times does each loop construct run?

A

While loops: zero or more times
Repeat/until loops*: at least once
For loops: a specific number of times

*Do not exist in Python

27
Q

Condition

A

A Boolean expression that controls an iteration or selection statement

28
Q

Structure chart

A

A diagram showing how a code module breaks down into smaller modules through sequence, selection and iteration

29
Q

Flowchart

A

A diagram using commonly defined symbols to express an algorithm

30
Q

Pseudocode

A

A way of writing an algorithm using programming constructs, but not in an actual language