3.2 Programming Flashcards

1
Q

String

A

Str
Statement

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

Integer

A

Int
Number

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

Float

A

Float
Decimal

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

Bool

A

Boolean
True/false

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

Real

A

Real
Decimal

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

Iteration

A

Repeating sections of code in a loop.
FOR, WHILE, REPEAT

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

Selection

A

Changing the direction of a programme based on a specific criteria
IF, SELECT, CASE

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

Indefinite loop

A

If you don’t know beforehand how many times the loop will repeat, you use an indefinite loop.
This is also called a condition-controlled loop because you decide when to stop looping depending on how a condition is set.

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

Pre-controlled loops

A

The condition is checked before the loop starts and will keep going whilst the condition is TRUE.

WHILE count < 5
count <— count + 1
ENDWHILE

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

Post-controlled loop

A

REPEAT
count <— count + 1
UNTIL count < 5

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

Definite loop

A

If you do know how many times the loop will repeat, you use a definite loop. This is also called a counter-controlled loop because the loop will repeat until the counter reaches a certain value.

FOR count <— 1 to 5
OUTPUT count
ENDFOR

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

Nested loops

A

Loops inside one another. The loop in the middle will then repeat every time for the outside loop.

FOR multiple <— 1 to 10
OUTPUT multiple + “times table”
FOR count <— 1 to 5
OUTPUT count *multiple
ENDFOR
ENDFOR

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

Nested IF statements

A

We can use multiple if statements within each other.

IF count < 10 THEN
IF count < 5 THEN
OUTPUT “Fail”
ELSE
OUTPUT “Pass”
ENDIF
ELSE
OUTPUT “Merit”
ENDIF

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

Relational operators:
Less than

A

<

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

Relational operators:
Greater than

A

>

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

Relational operators:
Equals

A

=

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

Relational operators:
Not equals

A

!=

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

Relational operators:
Less than or equal to

A

<=

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

Relational operators:
Greater than or equal to

A

> =

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

Arithmetic operators

A

• Addition
• Subtraction
• Multiplication *
• Division
• MOD
• DIV

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

Division

A

Gives a real number (decimal) as the result.
/

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

MOD

A

Finds the remainder when the first number is divided by the second.
%

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

DIV

A

Finds the whole part when the first number is divided by the second.
//

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

Boolean operators

A

Boolean operators refer to being able to compare one or two Boolean values and return either TRUE or FALSE.

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

NOT

A

This revers the input.
NOT TRUE = FALSE

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

AND

A

This checks if both inputs are TRUE and returns TRUE if so, FALSE otherwise.

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

OR

A

This checks if either input is TRUE and returns TRUE if so, FALSE otherwise.

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

Count controlled/definite loop

A

The number of iterations is known before the body of the loop is started.

29
Q

Condition controlled/indefinite loops

A

The number of iterations is not known before the body of the loop is started. The loop ends when a specific condition is met.

30
Q

Subroutine

A

A named, self contained block of instructions.
If we have a code that might be called repeatedly within a program, we can code it as a subroutine whenever needed.

31
Q

Why is a subroutine useful?

A

• Makes code more useful
• Makes code more maintainable

32
Q

How to do a subroutine in pseudocode?

A

SUBROUTINE [word] ()

ENDSUBROUTINE

33
Q

Procedure

A

May or may not return results through its parameters

34
Q

Function

A

Will return a single result.

35
Q

Parameters

A

A variable used to pass data into a sub program.

36
Q

Arguments

A

The value a parameter takes when a sub program is called.

37
Q

Parameters and argument

A

The contents of name in the main program is the argument. Name is the parameter.

38
Q

Global variable

A

When it is accessible from all parts of a program.

39
Q

Local variable

A

When it is accessible only within a function/procedure.

40
Q

Pattern recognition

A

Finding repeating patterns that could be solved quickly.

41
Q

Algorithm creation

A

Creating a step by step set of instructions to solve the problem.

42
Q

Identifier

A

Name of the function

43
Q

Process

A

The ‘doing’ stuff

44
Q

Output

A

The return value.

45
Q

Constants

A

Can’t change while the code is running.

46
Q

Variables

A

Can change value.

47
Q

Upper case and lower case

A

s.upper
s.lower

48
Q

IF statements

A

Check if a condition is true or false before running code.

49
Q

IF-ELSEIF statements

A

Check different conditions and run the code under the first one that is True.

50
Q

FOR loops

A

Repeat code a fixed number of times. Number of reacts depends on initial value and end value.

51
Q

While loops

A

Repeats while a condition is true. Condition checked at start of loop,

52
Q

Record

A

A data structure that steps related values of different data types.

53
Q

Field

A

An element of a record used to store on piece of data.

54
Q

File handling

A

newFile(“name of file”)
file = open(“myFile.txt”)
file.readLine()
file.writeLine(“text”)
file.endOfFile()
file.close()

55
Q

Procedure

A

A sub program that doesn’t return a value.

56
Q

Function

A

A sub program that does return a value.

57
Q

Sub program

A

A set of instructions under one name that are executed when called. They help to improve code structure, improve readability and avoid repeating code.

58
Q

Record

A

A Record is a data structure used to record data of multiple types about a single entity.
It is similar to a Table in database terms, but with none of the relational requirements – it is just a store of data

59
Q

Advantages of data structures

A

• Flexibility to expand how much data we store
• Ability to iterate over the structure
• Holding items of multiple data types together
• Easier code to write and understand
• Easier code to re-use

60
Q

Syntax errors

A

An error caused by not using the correct Syntax (Grammar). These are normally spelling errors, brackets, quotes…

61
Q

Logic errors

A

A fault in the logic or structure of the problem.
Likely to be Condition/Operator issues, using the wrong variables, incorrect counters…just getting your program wrong!

62
Q

Validation

A

Detecting data that is:
• Unreasonable
• Incomplete
• In the wrong format
It is picking up Human error in entering data
Our programs should Validate user input, rejecting and reporting invalid input when it occurs

Validation checks that date is
REASONABLE.
It does NOT check that it is ACCURATE

63
Q

Why validate?

A

• Crash Prevention
• We need to ensure that users can get data entry wrong.
• Robust programming doesn’t crash just because a user enters Sixteen rather than 16
• It should guide the user and keep asking until their input is successfully validated

64
Q

What happens if a user doesn’t pass a validation check?

A

• Give a message explaining the error
• Allow the input to be tried again
• Keep going until passed

65
Q

Validation types

A

Length check:
• Max and Min checks.
If we are converting a string to an age, it should be between 1 and 3 digits?
If we are asking for an initial, it should be 1 character long

Presence check:
• If a user input should not be empty

Type check:
• We might only expect them to enter the digits ‘0’ to ‘9’ (for a phone number for instance)

Range check:
• Is there a range a number should be. Perhaps entering an age on a booking form for a child ticket (11 – 16)

66
Q

Authentication

A

Verifying the identity of a user.

67
Q

3 authentication steps

A

• Identification. Requiring a person to identify themselves by means of an identification string (ie – a username)
• Authentication. Requiring a person to provide evidence of their identity - typically done with a password
• Authorisation. Allowing an authenticated person access to the system

68
Q

Testing

A

• Checking that our program does exactly what we (or the spec) wants it to do
• Testing the reliability of your program.
• We cannot realistically test EVERY input value so we need to create test data that systematically tests for different types of data
• Testing should be carried out in a way that reveals Logic Errors. You should know WHAT should happen, not just that valid entries are accepted.

69
Q

Test plans

A

Normal/Typical test data
• This should be designed in a way to test every path through your program

Boundary/Extreme test data
• Data that sits on the boundaries of conditions
• You test at either edge of the accepted validation limits – the first/last number that is VALID and the one next to it that is INVALID
• For example, if Valid data is from 1 to 10, boundary data is 0, 1, 10, 11
• Humans make errors ALL THE TIME in our conditions

Erroneous Test Data
• Invalid data (ie letter entered when integer expected, values out of the relevant range)