Logic and Languages Flashcards

1
Q

What does the arithmetic operator ‘modulus’ do? Give an example.

A

This finds the remainder from a floor division. For example, 16 // 3 = 5 and 5 x 3 = 15, so 16-15 = 1 so the remainder is 1.

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

What does the arithmetic operator ‘floor division’ do? Give an example.

A

Also known as ‘whole number division’ so only look at the numbers before the decimal point (the integers). For example, 16 // 3 = 5.3333.. therefore the whole number is 5.

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

What does the arithmetic operator ‘exponentiation’ do? Give an example.

A

It calculates the power of a number. For example 7**2 = 49

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

What is the python and pseudocode symbol for ‘modulus’?

A

16 MOD 3 (pseudocode)

16 % 3 (python)

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

What is the python and pseudocode symbol for ‘floor division’?

A

16 DIV 3 (pseudocode)

16 // 3 (python)

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

What is the python and pseudocode symbol for ‘exponentiation’?

A

7^2 (pseudocode)

7**2 (python)

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

What can logic statements be evaluated to? (1 mark)

A

True (1) or False (0)

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

What are the types of Boolean operators?

A

AND, OR & NOT

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

What is a truth table? (2 marks)

A

A truth table is a method of representing every possible output based on the inputs to a Boolean expression.

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

What is NOT also know as?

A

Negation

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

What is OR also known as?

A

Disjunction

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

What does the OR operator return?

A

The operator returns true if either of the conditions are true. It only returns false if both conditions are false.

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

What does the NOT operator do?

A

Takes one input an reverses it

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

What does the AND operator do?

A

Only returns true if both conditions are true, else it returns false.

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

What is the order of precedence?

A

NOT, then AND, then OR

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

How do you find out the number of rows on your truth table? (1 mark)

A
Do 2 (base) to the power of n (the number of inputs)
E.g. 2^3 = 8 rows
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What do comparison operators do? (1 mark)

A

Evaluate to a Boolean value

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

What do Boolean operators do? (2 marks)

A

Take Boolean inputs and evaluate to a Boolean value

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

What are the two types of testing? (2 marks)

A

Iterative testing

Final testing/terminal testing

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

What is iterative testing? (2 marks)

A

Iterative testing tests modules and parts of a program as the program is developed

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

What is final/terminal testing? (2 marks)

A
Final testing (also known as terminal testing) tests the whole
program at the end of production
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the purpose of testing? (2 marks)

A

To find errors and determine (then patch) vulnerabilities so the program functions as intended

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

What are the two types of errors? (2 marks)

A

Syntax error

Logic error

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

What is the syntax of a language? (1 mark)

A

It is the collection of rules that form its structure

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

What is a logic error? (2 marks)

A

Logic errors appear when the program’s execution appears to run as normal, but not as the programmer intended

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

What is a syntax error? (2 marks)

A

A syntax error is one where the programming code written doesn’t conform to the rules of the language

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

Why does a syntax error appear? (3 marks)

A

The compiler doesn’t know how to translate the program into

machine code so will give the programmer a syntax error. The program cannot be run until all syntax errors are fixed.

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

What does a test plan test for? (3 marks)

A

Boundary/extreme data
Erroneous/invalid data
Normal/typical data

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

What is normal data? Give an example. (2 marks)

A

Normal data is test data that is typical (expected) and should be accepted by the system. A number between 0-100, e.g. 5

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

What is boundary data? Give an example (2 marks)

A

Boundary data is test data at the upper or lower limits of expectations that should be accepted by the system. A number between 0-100, e.g. 0 and 100.

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

What is erroneous data? Give an example. (2 marks)

A

Erroneous data is test data that falls outside of what is acceptable and should be rejected by the system. A number between 0-100, e.g. “ade”

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

What is a trace table useful for? (3 marks)

A

Determining the purpose of an algorithm
Finding the output of an algorithm
Finding errors in an algorithm

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

How is a trace table used to help find errors in a program? (3 marks)

A

Variable names and outputs are put in columns. The programmer traces through the program line by line updating the values of variables and outputs. A row is used for each iteration.

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

What is a trace table? (2 marks)

A

This is where the programmer goes through the code, line by line, writing down the values of variables

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

What is the difference between iterative and final testing? (2 marks)

A

In iterative testing, the programmer will usually test the code with knowledge of how it works. Whereas in final testing, the program may be tested by the programmer or end-user

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

What is data validation? (2 marks)

A

Checks data meets a set of criteria before you process it and can ensure that data entered is of the right type.

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

What is the difference between validation and verification? (2 marks)

A

Validation can only check that the data entered is reasonable
Verification is used to double-check that the data has been typed in correctly

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

What are the types of validation checks?

A
Range check
Type check
Length check
Presence check
Format check
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What is a range check? (2 marks)

A

A number or date is within a sensible/allowed range

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

What is a type check? (2 marks)

A

Data is of the right type, such as integer, letter or text

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

What is a length check? (2 marks)

A

Text entered is not too long or too short – for example, a password is between 8 and 15 characters

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

What is a presence check? (2 marks)

A

Checks that data has been entered, i.e. the field has not been left blank

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

What is a format check? (2 marks)

A

Checks that the format of, for example, a postcode or email address is correct

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

What is authentication? (2 marks)

A

Authentication – entering data twice or checking from an alternative source

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

What is an example of anticipating misuse? (2 marks)

A

Anticipating misuse – preventing too many entries of a password to make it harder for hackers to guess

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

What is the purpose of authentication routines? (2 marks)

A

Authentication routines are used to make sure a person is who they claim to be

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

What is the purpose of data sanitisation? (2 marks)

A

The purpose of data sanitisation is to hide or protect data so it can’t be seen or disclosed, it involves modifying an input to make it valid.

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

What are the types of data sanitisation? (2 marks)

A

Masking

Input sanitisation

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

What is input sanitisation? (2 marks)

A

The process of checking data and removing dangerous inputs which could otherwise be used to cause damage to a program

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

What is masking? (1 mark)

A

Hiding visible data

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

What is an example of input sanitisation? (2 marks)

A

SQL injections, which involves the use of SQL code in a website form to try and hack into a database

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

What is a common method of online authentication? (1 mark)

A

Password routines

53
Q

What can a trace table test for? (1 mark)

A

Logic errors

54
Q

How can programs be written in a way that makes them easily maintainable? (4 marks)

A

Indentation
Commenting
Use of sub programs
Appropriate naming conventions

55
Q

How is a program maintained? (2 marks)

A

By improving the code, fixing bugs or adding new features to the program

56
Q

Why are sub programs used? (2 marks)

A

To create reusable code where bugs can easily be fixed

57
Q

What is appropriate naming conventions? (2 marks)

A

It is good use of variables and sub program names to make the programs easier to read

58
Q

Why is indentation used? (2 marks)

A

Indentation makes it possible to easily see which lines of code are part of different structures (show nesting) - easier to read

59
Q

Why is commenting used? (2 marks)

A

Commenting helps programmers understand what a program does and how it does it

60
Q

What are programming languages? (2 marks)

A

They are formal constructed languages designed to communicate instructions to a machine.

61
Q

What is an advantage of machine code? (2 marks)

A

It requires the least abstraction, which means the processor can execute the code directly - more optimised

62
Q

What is machine code written in? (1 mark)

A

Binary or hexadecimal numbers

63
Q

What are the disadvantages of machine code? (3 marks)

A

Writing programs is difficult
Writing programs is time-consuming
It is specific to a processor and corresponds to its instruction set (not portable)

64
Q

What are some examples of low level language?

A

Machine code

Assembly code

65
Q

What is an instruction set? (2 marks)

A

The complete set of all the instructions in machine code that can be recognised and executed by a CPU

66
Q

What is assembly code made up of? (1 mark)

A

Simple mnemonics

67
Q

What are some disadvantages of assembly code? (2 marks)

A

It is processor-specific

It has to be translated into machine code before it can be executed

68
Q

Why is assembly language a low-level language? (2 mark)

A

As each instruction corresponds directly to a machine code instruction (have an almost one-to-one relationship with machine code)

69
Q

What are some examples of high-level languages? (5 marks)

A
Python
Java
C++
Ruby
C#
70
Q

What are the advantages of high-level languages? (4 marks)

A

Easier to learn
Programs can be written faster in a high-level language
It is easier to understand and debug a high-level language
Not hardware-specific (portable) - therefore can be executed on many computers with the correct translator

71
Q

Why are high-level languages usually slower to execute when compared to low-level languages? (4 marks)

A

High-level languages have a lot of abstractions and layers of code before they reach the hardware itself. This code then needs to be translated into machine code. Therefore more work needs to be done at runtime, whereas, less abstract languages can optimise more.

72
Q

How is high-level language translated? (2 marks)

A

By a compiler or interpreter

73
Q

What is a translator? (2 marks)

A

A program that converts code from one language into equivalent code written in another - as all code needs to be translated to machine code.

74
Q

What are the types of translators? (3 marks)

A

Assembler
Interpreter
Compiler

75
Q

What is an assembler? (2 marks)

A

Uses the processor’s instruction set to convert instructions in assembly code to the machine code equivalent

76
Q

What is the output of an assembler? (1 mark)

A

An object file

77
Q

How would optimisation occur in assemblers? (2 marks)

A

substituting subprogram calls as if they were inline

calculating the values of constants

78
Q

What is the advantage of assembly code? (2 marks)

A

You can program directly, which is used for writing specific instructions for embedded systems (e.g. washing machine)

79
Q

What is an embedded system? (2 marks)

A

A microprocessor designed to perform dedicated functions within a larger computing system. It includes RAM, ROM and a CPU.

80
Q

What is a compiler? (2 marks)

A

A compiler translates a high-level language into machine code. It produces a compiled program that can be directly executed.

81
Q

What is the code written by a programmer called? (1 mark)

A

source code

82
Q

What is the code written by a compiler called?

A

object code

83
Q

Where can object code be saved in? (2 marks)

A

Object code can be saved in a storage drive and run whenever required. It must either be placed in an executable file, a library file, or an object file.

84
Q

What is the disadvantage of a compiler? (2 marks)

A

Error messages are only shown after scanning the whole code, which can be time-consuming when debugging.

85
Q

What are some advantages of a compiler? (3 marks)

A

After translation, the compiler and source code is no longer needed - this means you can distribute your program without the source code
A compiled program executes faster as it is already in machine code
Once compiled, the source code cannot be edited or adapted

86
Q

What is an interpreter? (2 marks)

A

An interpreter is another type of program that translates a high-level language into machine code

87
Q

What are some advantages of an interpreter? (3 marks)

A

It translates each line of code and executes it immediately
If it reaches a line with a syntax error, it stops and displays an error message
Interpreted code can run on any computer with an interpreter which makes it more portable

88
Q

What is the difference between a compiler and an interpreter? (2 marks)

A

A compiler scans through the whole code and translates it into machine code. An interpreter works line-by-line, it translates a line and then immediately executes it.

89
Q

What are some examples of compiled programming languages? (2 marks)

A

Java

C++

90
Q

What are some examples of interpreted programming languages? (4 marks)

A

JavaScript
PHP
Python
Ruby

91
Q

What are some disadvantages of an interpreter? (3 marks)

A

Takes more time to execute as each instruction is translated before it is executed
The interpreter must be installed and source code is required to run the program
Source code can be edited or adapted

92
Q

What is a virtual machine? (2 marks)

A

A process virtual machine is a programming environment that allows a program written for one type of machine, to run on other types of machines, without any changes being necessary.

93
Q

What is bytecode? (3 marks)

A

Bytecode is source code that has been compiled into low-level code and can be interpreted on many different types of processors using an interpreter. It is an intermediate stage between high-level and low-level language.

94
Q

Why is some language compiled to bytecode? (1 mark)

A

For performance

95
Q

What language compiles to bytecode? (1 mark)

A

Java

96
Q

What is an IDE? (1 mark)

A

Integrated Development Environment

97
Q

What is the purpose of an IDE? (2 marks)

A

An application that provides a selection of tools for programmers, allowing them to code using additional tools all in one place

98
Q

What are some examples of IDEs in programming languages? (3 marks)

A

Visual Studio (C#)
Eclipse (Java)
IDLE (Python)

99
Q

What is a code editor? (2 marks)

A

The code editor is a text edit area that allows developers to write, edit and save a document of code.

100
Q

What is an example of a visual code editor? (1 mark)

A

Syntax highlighting

101
Q

What are runtime errors? (2 marks)

A

Runtime errors are errors which will cause the program or computer to crash even if there appears to be nothing wrong with the program code

102
Q

What is a common cause of runtime errors? (2 marks)

A

Running out of memory - because instructions have been written in the wrong order.

103
Q

Why use error diagnostics? (2 mark)

A

Error diagnostics help a programmer to find where they have made a mistake

104
Q

What are some examples of error diagnostics? (3 marks)

A

Inline syntax highlighting
Debug mode
Line numbers

105
Q

What are line numbers? (3 marks)

A

Line numbers allow a programmer to clearly see each new line of code
When errors are found, the line number that they occur on will also be stated

106
Q

What is syntax highlighting? (3 marks)

A

Syntax highlighting is where the colour of the text changes to show different parts of the program. Errors are also highlighted/underlined.

107
Q

What is a method of debugging code? (1 mark)

A

Breakpoints

108
Q

What is variable watching? (2 marks)

A

Variable watching is the process of inspecting the value of a variable while the program is executing in debug mode

109
Q

What are breakpoints? (1 mark)

A

A point in the program where the code will stop executing.

110
Q

Why are breakpoints set? (2 marks)

A

Breakpoints are set by the programmer so that the IDE stops the program mid-way through running

111
Q

What do breakpoints allow a programmer to do? (2 marks)

A

Step through the code line by line

They can watch variables as they change

112
Q

What is the purpose of stepping? (2 mark)

A

It executes the code one line at a time to check for errors.

113
Q

What is a runtime environment? (1 marks)

A

Allows the programmer to test their program while it is running

114
Q

What are some examples of code editors? (3 marks)

A

Auto-completion
Syntax checks
Bracket matching

115
Q

What does a runtime environment allow the programmer to do? (2 marks)

A

Execute the program line by line and give useful information to the programmer if the program was to crash

116
Q

What is auto-completion? (2 marks)

A

As you start to type the first part of a function, it suggests or completes the function and any arguments or variables

117
Q

What is bracket matching? (2 marks)

A

It uses pairs of brackets to mark out blocks of code- which allows the code to be read and understood more quickly.

118
Q

What are syntax checks? (2 marks)

A

This recognises incorrect use of syntax and highlights any errors

119
Q

What are some examples of IDEs? (6 marks)

A
Translator
Build automation
Debugging tools
Run-time environment
Syntax highlighting
Auto documentation
120
Q

What does the runtime environment allow the programmer to access? (1 mark)

A

The libraries that come with the programming language

121
Q

What does auto-documentation do? (2 marks)

A

This explains the function and purpose of the code

122
Q

What is build automation? (2 marks)

A

These tools save time by automatically doing the processes that would otherwise be done by hand (e.g. testing or compiling)

123
Q

What are importing libraries? (2 marks)

A

Importing libraries provide functions that are not included in the core part of the programming language

124
Q

What are constants? (2 marks)

A

Data values that stay the same every time a program is executed

125
Q

What is the purpose of optimisation? (1 mark)

A

To make your code more efficient

126
Q

Why do computers use binary? (1 mark)

A

So that computers can be based on logic circuits

127
Q

What is the name of the electrical components that are contained in the CPU, consisting in one of two states (on/off)?

A

Transistor

128
Q

What are the features of a low level language

A

Runs quickly
Requires less RAM
can manipulate hardware
Processor-specific has to be translated into machine code

129
Q

What is the relationship between transistors, logic gates and logic circuits? (2 marks)

A

Logic gates are made of transistors.

Logic circuits are made of logic gates.