1.2.3 Intro to Programming [OUT OF SERVICE] Flashcards

1
Q

Programming construct: Sequence

A

Code is executed line-by-line from top to bottom

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

Programming construct: Selection

A

Certain block of code is run if a specific condition is met, using IF, ELSE IF and ELSE statements

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

Programming construct: Iteration

A

A block of code is executed a certain number of times or while a condition is met, using FOR, WHILE or DO UNTIL loops

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

What is a variable?

A

A name used to refer to a particular memory location used to store data.

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

What operator is this: =

A

Assignment

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

What is the difference between constants and variables?

A

Value of a constant cannot be edited by the program during execution.

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

What might we use a constant for?

A

Values that don’t need changing.

EG: VAT, Pi

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

Programming construct: Subroutine

A

Named blocks of code that perform a specific task.

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

How many values can a function return?

A

One.

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

What are parameters?

A

Values passed into a subroutine.

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

Arithmetic operator: **

A

Exponentiation (raising a number to a power)

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

Arithmetic operator: DIV or //

A

Integer division

Whole number of times a number goes into another

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

Arithmetic operator: MOD

A

Remainder when a number is divided by another

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

What are arithmetic and relational operators used for?

A

Arithmetic: Carrying out mathematical functions
Relational: Making comparison between 2 values

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

Boolean operator: AND

A

Returns true when both values true

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

Boolean operator: OR

A

Returns true when at least one value is true

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

How do you get the length of a string?

A

stringname.length

18
Q

What is a substring?

A

A section within a string

19
Q

How do you get a substring?

A

stringname.subString(startPos, numOfChar)

20
Q

How can you open a file to read?

A

myFile = openRead(“filename.txt”)

21
Q

How can you read a line from a file?

A

fileContent = myFile.readLine()

22
Q

How can you close a file?

A

myFile.close()

23
Q

How can you open a file to write?

A

myFile = openWrite(“filename.txt”)

24
Q

How can you write a line to a file?

A

myFile.writeLine(“Lovely weather outside”)

25
Q

What is the end of the file given by?

A

endOfFile()

26
Q

Why is assembly easier to use than machine?

A

It uses mnemonics.

27
Q

What is each assembly language mnemonic represented by?

A

A numerical code.

28
Q

Why are assembly language commands processor specific?

A

They interact directly with the CPU’s registers.

29
Q

What sort of system might assembly language be used in? Why?

A

Embedded system, due to direct interaction with hardware

30
Q

Mnemonic Function: ADD

A

Add the value at the given memory address to the

value in the Accumulator

31
Q

Mnemonic Function: SUB

A

Subtract the value at the given memory address from the value in the Accumulator

32
Q

Mnemonic Function: STA

A

Store the value in the Accumulator at the given

memory address

33
Q

Mnemonic Function: LDA

A

Load the value at the given memory address into the

Accumulator

34
Q

Mnemonic Function: INP

A

Allows the user to input a value which will be held in

the Accumulator

35
Q

Mnemonic Function: OUT

A

Prints the value currently held in the Accumulator

36
Q

Mnemonic Function: HLT

A

Stops the program at that line, preventing the rest of

the code from executing.

37
Q

Mnemonic Function: DAT

A

Creates a flag with a label at which data is stored.

38
Q

Mnemonic Function: BRZ

A

Branches to a given address if the value in the

Accumulator is zero. This is a conditional branch.

39
Q

Mnemonic Function: BRP

A

Branches to a given address if the value in the

Accumulator is positive. This is a conditional branch.

40
Q

Mnemonic Function: BRA

A

Branches to a given address no matter the value in

the Accumulator. This is an unconditional branch.