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
NOT
This revers the input. NOT TRUE = FALSE
26
AND
This checks if both inputs are TRUE and returns TRUE if so, FALSE otherwise.
27
OR
This checks if either input is TRUE and returns TRUE if so, FALSE otherwise.
28
Count controlled/definite loop
The number of iterations is known before the body of the loop is started.
29
Condition controlled/indefinite loops
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
Subroutine
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
Why is a subroutine useful?
• Makes code more useful • Makes code more maintainable
32
How to do a subroutine in pseudocode?
SUBROUTINE [word] () ENDSUBROUTINE
33
Procedure
May or may not return results through its parameters
34
Function
Will return a single result.
35
Parameters
A variable used to pass data into a sub program.
36
Arguments
The value a parameter takes when a sub program is called.
37
Parameters and argument
The contents of name in the main program is the argument. Name is the parameter.
38
Global variable
When it is accessible from all parts of a program.
39
Local variable
When it is accessible only within a function/procedure.
40
Pattern recognition
Finding repeating patterns that could be solved quickly.
41
Algorithm creation
Creating a step by step set of instructions to solve the problem.
42
Identifier
Name of the function
43
Process
The ‘doing’ stuff
44
Output
The return value.
45
Constants
Can’t change while the code is running.
46
Variables
Can change value.
47
Upper case and lower case
s.upper s.lower
48
IF statements
Check if a condition is true or false before running code.
49
IF-ELSEIF statements
Check different conditions and run the code under the first one that is True.
50
FOR loops
Repeat code a fixed number of times. Number of reacts depends on initial value and end value.
51
While loops
Repeats while a condition is true. Condition checked at start of loop,
52
Record
A data structure that steps related values of different data types.
53
Field
An element of a record used to store on piece of data.
54
File handling
newFile(“name of file”) file = open(“myFile.txt”) file.readLine() file.writeLine(“text”) file.endOfFile() file.close()
55
Procedure
A sub program that doesn’t return a value.
56
Function
A sub program that does return a value.
57
Sub program
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
Record
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
Advantages of data structures
• 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
Syntax errors
An error caused by not using the correct Syntax (Grammar). These are normally spelling errors, brackets, quotes...
61
Logic errors
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
Validation
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
Why validate?
• 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
What happens if a user doesn’t pass a validation check?
• Give a message explaining the error • Allow the input to be tried again • Keep going until passed
65
Validation types
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
Authentication
Verifying the identity of a user.
67
3 authentication steps
• 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
Testing
• 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
Test plans
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)