Slr 1 Flashcards

1
Q

Define program

A

A program is a series of statements

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

What are the three programming constructs?

A

Sequence
Selection
Iteration

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

Define sequence

A

Executing one instruction after another

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

Define selection

A

Allows a program to branch and follows a different direction depending on the outcome of a condition
E.g. if statement

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

Define iteration

A

Repeating sections of code
E.g. for loop, while loop, do until

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

Define nesting

A

Process of putting one statement inside another

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

Is for loop condition or count

A

Count controlled loop

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

Is while loop condition or count

A

Condition controlled loop

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

Define variable

A

A value that can change while the program is running. It is a (named) address in memory

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

Define constant

A

Value that remains fixed, as it does not change while the program is running. It must be set when the program is first written

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

Define assignment

A

Supply a value to a variable or constant. Performed with a =

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

Define Subroutine

A

Block of code given a unique, identifiable name within a program

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

Why use subroutines

A

To break down a larger problem into a series of smaller, more manageable problems, making them easier to:
Code
Debug
Reuse

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

Define procedures

A

Are blocks of code that carry out a set task

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

Define function

A

Blocks of code that carry out a set task and returns a value

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

What do procedures do?

A

Carry out a task
Provide structure to code

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

What do functions do?

A

Carry out a task
Returns a value
Create reusable program components

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

Advantages of subroutines

A

Programs are easier to write
Programs are easier to debug
Creates re useable components
Functions can be grouped in a library for easy reuse access across multiple programs
Programs are easier to test

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

Sign for addition

A

+

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

Sign for subtraction

A

-

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

Sign for multiplication

A

*

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

Sign for division (d.p)

A

/

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

Sign for exponential

A

Or **

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

Sign for modulus

A

//

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

Sign for equal to

A

==

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

Sign for not equal to

A

!=

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

Sign for less than

A

<

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

Sign for less than or equal to

A

<=

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

Sign for greater than

A

>

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

Sign for greater than or equal to

A

> =

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

Where are Boolean operators used

A

In Boolean expressions- present in selection and iteration statements

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

What are the Boolean operators.

A

Not
And
Or

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

Define string manipulation

A

Act of manipulating, extracting or changing the characters in a string variable

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

String function

A

String functions are often built into a programming language to manipulate the string data type

35
Q

What does file handling involve

A

Opening
Closing
Reading to
Writing from
Files by program code

36
Q

Define data dependency

A

The program requires the items from the text file to be in a specific order

37
Q

Open file for reading

A

Command takes two parameters
-characters- the name of the file to open
-r what you want to do with the file

38
Q

Open file for writing

A

Open command takes two parameters
- characters- name of the file to open
- a/w- what you want to do with the file (append/ write)

39
Q

What does /n mean

A

Start a new line

40
Q

Assembly languages

A

Substituted binary code with simple sequences of letters known as mnemonics. All assembly languages are classified as low level languages.
Assembly language is directly translated into binary machine code by an assembler

41
Q

LMC (RAM)

A

100 memory locations (0-99)

42
Q

LMC (CPU)

A

An ALU
An accumulator to store the results of the last operation or calculation
A program counter to store the address of the next instruction in memory
An instruction register to hold the first digit of the instruction read from memory
An address register to hold the second and third digits of instruction read from memory

43
Q

Assembler (LMC)

A

Allows us to name addresses- labels

44
Q

Define label

A

Any word that is not a recognised instruction is assumed to be a label

45
Q

Label before instruction

A

The LMC defines the label as representing that address

46
Q

Label after instruction

A

The address is substituted for the label

47
Q

Three parts the LMC code can be

A

Label
Mnemonic
Data it applies to

48
Q

What does 0 mean (LMC)

A

HLT

49
Q

HLT description

A

Stops the program

50
Q

What does 1 mean (LMC)

A

ADD

51
Q

What does 2 mean (LMC)

A

SUB

52
Q

What does 3 mean (LMC)

A

STA / STO

53
Q

What does 4 mean (LMC)

A

Unused

54
Q

What does 5 mean (LMC)

A

LDA

55
Q

What does 6 mean (LMC)

A

BRA

56
Q

What does 7 mean (LMC)

A

BRZ

57
Q

What does 8 mean (LMC)

A

BRP

58
Q

What does 9 mean (LMC)

A

INP/ OUT

59
Q

Description of ADD

A

Adds the contents of the memory address to the accumulator

60
Q

Description of SUB

A

Subtract the contents of the memory address from the accumulator

61
Q

Description of STA/ STO

A

Store the value currently stored in the accumulator in the memory address

62
Q

Description of 4

A

The code is unused and gives an error

63
Q

Description of LDA

A

Load the contents of the memory address into the accumulator

64
Q

Description of BRA

A

Use the memory address as the address of the next instruction

65
Q

Description of BRZ

A

Branch to the memory address of the accumulator is zero

66
Q

Description of BRP

A

Branch to the memory address of the accumulator is zero or positive

67
Q

Description of INP/ OUT

A

Take from the input if the address is 1; copy to the output if the address is 2

68
Q

Description of DAT

A

Indicates a location that contains data

69
Q

What does the pc hold?

A

Only two digits (0-99)

70
Q

What does the accumulator hold

A

Three digits and a sign (-999 to 999)

71
Q

What does the code do

<file>=open(<file>,”r”)
</file></file>

A

Opens a file for reading

72
Q

What does the code do
<a> = <file>.readline()</file></a>

A

Returns a line from a file- or empty string if end of file has been reached

73
Q

What does the code do

<file> = open(<file>, “w”)
</file></file>

A

Opens a file for writing

74
Q

What does the code do

<file> = open(<file>, “a”)
</file></file>

A

Opens a file for appending

75
Q

What does the code do

<file>.write(<a>)
</a></file>

A

Writes a single string to a file

76
Q

What does the code do

<file>.close()
</file>

A

Closes file

77
Q

What does the code do

<string>.upper
</string>

A

Returns the original string in upper case

78
Q

What does the code do

<string>.lower
</string>

A

Returns the original string in lower case

79
Q

What does the code do

<string>.isupper
</string>

A

Returns true, if all characters are uppercase

80
Q

What does the code do

<string>.islower
</string>

A

Returns true, if all characters are lower case

81
Q

Parameter

A

A parameter is a variable in a function definition. It is a placeholder and hence does not have a concrete value.

82
Q

Argument

A

An argument is a value passed during function invocation.

83
Q

Global variables

A

Variables declared outside of the functions have a global scope and can be accessed within and outside of functions.

84
Q

Local variable

A

Variables declared in a function have a local scope and are therefore specific to the function at that time and cannot be referenced outside of the function unless they are declared as global variables in the function.