Section 2 - Programming Flashcards

1
Q

What are the five data types and what type of data are they used for?

A
  • – Integer: a whole number
  • – Float: a decimal number
  • – Boolean: true or false
  • – Character: a single character like a letter, number etc.
  • – String: zero or more characters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an example of definite iteration?

A

FOR i

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

What is an example of indefinite iteration with the condition at the start?

A

WHILE Notsolved
Instructions here…
ENDWHILE

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

What is an example of indefinite iteration with the condition at the end?

A

REPEAT
Instructions here…
UNTIL Solved

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

What is nested selection and nested iteration?

A

This is when you have a selection or iteration programme within another selection or iteration programme.

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

What are the seven arithmetic operations?

A
Arithmetic operations:
\+ (addition)
- (subtraction)
* (multiplication)
/ (division) 
^ (exponential)
// (DIV): outputs whole number of division
% (MOD): outputs reminder of division
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the six comparison operators?

A
Comparison operations:
< (less than)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)
!= or <> (not equal to)
= or == (equal to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the three logical operations for boolean expressions and when are they used?

A
  • – AND: when both expressions are true
  • – OR: when only one expression needs to be true
  • – NOT: inverses true to false and false to true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are two advantages of using arrays?

A
  • – Codes are easier to follow and easier to debug and maintain
  • – Can easily be processed by a FOR loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you get the length, substring and position of a string?

A

Length:
— LEN (stringExp) e.g. LEN (“Hello World”) would evaluate to 11

Substring:
— SUBSTRING (startPos, endPos, stringExp) e.g. SUBSTRING (3, 8, “Hello World”) evaluates to “lo Wor”

POSITION:
— POSITION (stringExp, char) e.g. POSITION (“Hello World”, d) evaluates to 10

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

What is concatenation?

A

Concatenation:

— Joining two or more strings together

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

How do you convert characters to and from ASCII?

A

CHAR_TO_CODE (“A”) evaluates to 65

CODE_TO_CHAR (66) evaluates to “B”

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

What are the functions you would use for these string handing operations:

  • – String to integer
  • – String to real
  • – Integer to string
  • – Real to string
A
  • – STRING_TO_INT (StringExp) e.g. STRING_TO_INT (“45”) evaluates to 45
  • – STRING_TO_REAL (StringExp) e.g. STRING_TO_REAL (“72.5”) evaluates to 72.5
  • – INT_TO_STRING (StringExp) e.g. INT_TO_STRING (21) evaluates to “21”
  • – REAL_TO_STRING (StringExp) e.g. REAL_TO_STRING (3.142) evaluates to “3.142”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a subroutine?

A

Subroutine:

— A named “out of line” block of code that is executed (called) by simply writing its name in a program statement.

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

What is the function used for random number generation in python and pseudocode?

A

Python:
import random
x = random.randint(1,10)
print(x)

Pseudocode:
x = RANDOM_INT (1,10)

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

What are the advantages of using subroutines?

A
  • – Makes problem easier to solve.
  • – Can be used several times within a program.
  • – Can be stored in a subroutine library and used in other programs.
  • – Several programmers can work on a program together.
  • – Program maintenance is easier as its easier to change a problem in a subroutine.
17
Q

What is the difference between procedures and functions?

A

They are both self-contained sections of code that carry out a specific task however a function returns a value using a RETURN statement.

18
Q

Explain local variables and give advantages of them.

A

Local variables are variables found within a subroutine.
Local variables:
— only exist while the subroutine is executing
— are only accessible within the subroutine.

Advantages:

  • – Keeps subroutine self-contained which limits confusion between global variables
  • – Keeps program easier to debug and maintain
  • – Saves memory as space is freed up when subroutine completes.
19
Q

What is meant by testing in the context of algorithms and programs?

A

Tesiting is the act of checking if a program runs the way it was intended to run and produces the output expected.

20
Q

Compare the three types of errors when programming.

A

Syntax error:
— Spelling or grammar mistakes so when there are mistakes in the actual typing up of the code

Logic error:
— Problems with the actual execution of the code in the sense that although the program may run, it does not produce the expected outcome.

Runtime error:
— When the program crashes while the program is being executed. Possibly caused by an incorrect input midway through the program

21
Q

What is test data and describe the three types of test data?

A

Test data:
— Data that is entered to check if a program works effectively.

Normal (typical):
— Data within the allowed range so data that is valid

Boundary:
— Data which includes both ends of the allowed range as well as data just either side of the allowed range.

Erroneous:
— Any data that falls outside the allowed values and should be rejected by the system.

22
Q

What are the four columns needed in a test plan table?

A
  • – What is being tested
  • – Test data
  • – Expected outcome
  • – Actual outcome