Topic 2 Programming Flashcards

1
Q

Describe a variable.

A

A named location in the computers memory to store a single value which can change during the execution of a program. Eg radiusOfCircle

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

Describe a constant.

A

A named location in the computers memory to store a single value which CANNOT change during the execution of a program. Eg the value of Pi.

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

What is an identifier?

A

The NAME of a variable, constant, procedure or function.

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

What is meant by assignment?

A

Setting the specific value of a variable. Eg number = 2 means assign the value 2 to the variable called ‘number’.

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

List the arithmetic operators.

A

+, -, *, /, MOD, DIV, ^

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

Describe the arithmetic operator MOD

A

Modulus division. Returns the remainder after dividing one number by another. Eg 5 MOD 2 = 1

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

Describe the arithmetic operator DIV

A

Quotient division. Returns the whole number ignoring any remainder after dividing one number by another. Eg 5 DIV 2 = 2

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

Describe the the arithmetic operator ^

A

Exponential or power-of. Eg 3^2 = 9 (3 squared)

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

Describe the order or operations in arithmetic operators.

A

BIDMAS - Brackets, Indices, Division, Multiplication, Addition, Subtraction

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

What are relational operators used for?

A

To compare different items of data.

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

List/describe the 6 relational operators

A
= Equal To
<> Not Equal To
< Less Than
> Greater Than
<= Less Then or Equal To
>= Greater Than or Equal To
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are logical operators used for?

A

To combine statements which can be evaluated as TRUE or FALSE.

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

Name the three logical operators.

A

AND, OR, NOT

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

Describe the AND logical operator

A

The overall statement is true only if ALL of the individual statements are true.

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

Describe the OR logical operator.

A

The overall statement is true if ANY of the individual statements are true.

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

Describe the NOT logical operator.

A

Used to reverse the logical state of other operators.

17
Q

What are the three main programming constructs?

A

Sequence, Selection & Iteration

18
Q

Describe the sequence construct.

A

Executing lines of code in the order they are written.

19
Q

Describe the selection construct.

A

Choosing which lines of code to execute based on a condition being true or false.

20
Q

Describe the iteration construct.

A

Repeating lines of code either for a set number of times, or while a condition is true.

21
Q

List and describe the five main data types.

A

Integer - Whole numbers.
Real - Numbers which include fractions/decimals.
Boolean - one of two values - usually True or False.
Character - A single letter, number or symbol.
String - A sequence of characters.

22
Q

What is meant by a ‘string literal’?

A

Characters enclosed in quotation marks.

Eg name = “Billy” - Billy is the string literal.

23
Q

Describe ‘string concatenation’.

A
Joining two strings together.
For example:
fname = "Billy"
sname = "Smith"
fullname = fname + sname  (concatenated)
24
Q

Describe an array.

A

An array is a data structure which can store multiple data items using a single identifier/name. Elements of the array are accessed using an index number which starts from 0.

25
Q

What is a two-dimensional array?

A

A data structure which uses two index numbers. The array would look like a grid/matrix and elements are accessed using the two indices.
For example array[2,4]

26
Q

What is a sub-procedure or sub-program?

A

A self contained sequence of program instructions that perform a specific task.

27
Q

Why are sub-programs useful?

A
  • Help with decomposition of a problem
  • Make programs shorter as they can be re-used
  • Make code easier to read and test
  • Can shorten development time
28
Q

What are the two types of sub-program?

A
  • Functions

- Procedures

29
Q

What is the difference between a function and a procedure?

A

Functions return at least one value to the main program.

Procedures carry out a specific task without returning a value to the main program.

30
Q

What is a parameter?

A

A value or piece of data passed into a function or procedure (sub-program).

31
Q

What is validation?

A

Program code which checks that the data input is sensible, reasonable and appropriate.
For example:
In a program where the user was expected to enter a number between 1 and 10, validation would check:
a. A number was entered
b. That number lies between 1 and 10

32
Q

Why is validation important?

A

Ensures that:

  • number of user errors are minimised
  • program behaves as expected in spite of user actions