Logic and Languages Flashcards

(129 cards)

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
What is a logic error? (2 marks)
Logic errors appear when the program's execution appears to run as normal, but not as the programmer intended
26
What is a syntax error? (2 marks)
A syntax error is one where the programming code written doesn’t conform to the rules of the language
27
Why does a syntax error appear? (3 marks)
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.
28
What does a test plan test for? (3 marks)
Boundary/extreme data Erroneous/invalid data Normal/typical data
29
What is normal data? Give an example. (2 marks)
Normal data is test data that is typical (expected) and should be accepted by the system. A number between 0-100, e.g. 5
30
What is boundary data? Give an example (2 marks)
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.
31
What is erroneous data? Give an example. (2 marks)
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"
32
What is a trace table useful for? (3 marks)
Determining the purpose of an algorithm Finding the output of an algorithm Finding errors in an algorithm
33
How is a trace table used to help find errors in a program? (3 marks)
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.
34
What is a trace table? (2 marks)
This is where the programmer goes through the code, line by line, writing down the values of variables
35
What is the difference between iterative and final testing? (2 marks)
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
36
What is data validation? (2 marks)
Checks data meets a set of criteria before you process it and can ensure that data entered is of the right type.
37
What is the difference between validation and verification? (2 marks)
Validation can only check that the data entered is reasonable Verification is used to double-check that the data has been typed in correctly
38
What are the types of validation checks?
``` Range check Type check Length check Presence check Format check ```
39
What is a range check? (2 marks)
A number or date is within a sensible/allowed range
40
What is a type check? (2 marks)
Data is of the right type, such as integer, letter or text
41
What is a length check? (2 marks)
Text entered is not too long or too short – for example, a password is between 8 and 15 characters
42
What is a presence check? (2 marks)
Checks that data has been entered, i.e. the field has not been left blank
43
What is a format check? (2 marks)
Checks that the format of, for example, a postcode or email address is correct
44
What is authentication? (2 marks)
Authentication – entering data twice or checking from an alternative source
45
What is an example of anticipating misuse? (2 marks)
Anticipating misuse – preventing too many entries of a password to make it harder for hackers to guess
46
What is the purpose of authentication routines? (2 marks)
Authentication routines are used to make sure a person is who they claim to be
47
What is the purpose of data sanitisation? (2 marks)
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.
48
What are the types of data sanitisation? (2 marks)
Masking | Input sanitisation
49
What is input sanitisation? (2 marks)
The process of checking data and removing dangerous inputs which could otherwise be used to cause damage to a program
50
What is masking? (1 mark)
Hiding visible data
51
What is an example of input sanitisation? (2 marks)
SQL injections, which involves the use of SQL code in a website form to try and hack into a database
52
What is a common method of online authentication? (1 mark)
Password routines
53
What can a trace table test for? (1 mark)
Logic errors
54
How can programs be written in a way that makes them easily maintainable? (4 marks)
Indentation Commenting Use of sub programs Appropriate naming conventions
55
How is a program maintained? (2 marks)
By improving the code, fixing bugs or adding new features to the program
56
Why are sub programs used? (2 marks)
To create reusable code where bugs can easily be fixed
57
What is appropriate naming conventions? (2 marks)
It is good use of variables and sub program names to make the programs easier to read
58
Why is indentation used? (2 marks)
Indentation makes it possible to easily see which lines of code are part of different structures (show nesting) - easier to read
59
Why is commenting used? (2 marks)
Commenting helps programmers understand what a program does and how it does it
60
What are programming languages? (2 marks)
They are formal constructed languages designed to communicate instructions to a machine.
61
What is an advantage of machine code? (2 marks)
It requires the least abstraction, which means the processor can execute the code directly - more optimised
62
What is machine code written in? (1 mark)
Binary or hexadecimal numbers
63
What are the disadvantages of machine code? (3 marks)
Writing programs is difficult Writing programs is time-consuming It is specific to a processor and corresponds to its instruction set (not portable)
64
What are some examples of low level language?
Machine code | Assembly code
65
What is an instruction set? (2 marks)
The complete set of all the instructions in machine code that can be recognised and executed by a CPU
66
What is assembly code made up of? (1 mark)
Simple mnemonics
67
What are some disadvantages of assembly code? (2 marks)
It is processor-specific | It has to be translated into machine code before it can be executed
68
Why is assembly language a low-level language? (2 mark)
As each instruction corresponds directly to a machine code instruction (have an almost one-to-one relationship with machine code)
69
What are some examples of high-level languages? (5 marks)
``` Python Java C++ Ruby C# ```
70
What are the advantages of high-level languages? (4 marks)
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
Why are high-level languages usually slower to execute when compared to low-level languages? (4 marks)
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
How is high-level language translated? (2 marks)
By a compiler or interpreter
73
What is a translator? (2 marks)
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
What are the types of translators? (3 marks)
Assembler Interpreter Compiler
75
What is an assembler? (2 marks)
Uses the processor's instruction set to convert instructions in assembly code to the machine code equivalent
76
What is the output of an assembler? (1 mark)
An object file
77
How would optimisation occur in assemblers? (2 marks)
substituting subprogram calls as if they were inline | calculating the values of constants
78
What is the advantage of assembly code? (2 marks)
You can program directly, which is used for writing specific instructions for embedded systems (e.g. washing machine)
79
What is an embedded system? (2 marks)
A microprocessor designed to perform dedicated functions within a larger computing system. It includes RAM, ROM and a CPU.
80
What is a compiler? (2 marks)
A compiler translates a high-level language into machine code. It produces a compiled program that can be directly executed.
81
What is the code written by a programmer called? (1 mark)
source code
82
What is the code written by a compiler called?
object code
83
Where can object code be saved in? (2 marks)
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
What is the disadvantage of a compiler? (2 marks)
Error messages are only shown after scanning the whole code, which can be time-consuming when debugging.
85
What are some advantages of a compiler? (3 marks)
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
What is an interpreter? (2 marks)
An interpreter is another type of program that translates a high-level language into machine code
87
What are some advantages of an interpreter? (3 marks)
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
What is the difference between a compiler and an interpreter? (2 marks)
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
What are some examples of compiled programming languages? (2 marks)
Java | C++
90
What are some examples of interpreted programming languages? (4 marks)
JavaScript PHP Python Ruby
91
What are some disadvantages of an interpreter? (3 marks)
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
What is a virtual machine? (2 marks)
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
What is bytecode? (3 marks)
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
Why is some language compiled to bytecode? (1 mark)
For performance
95
What language compiles to bytecode? (1 mark)
Java
96
What is an IDE? (1 mark)
Integrated Development Environment
97
What is the purpose of an IDE? (2 marks)
An application that provides a selection of tools for programmers, allowing them to code using additional tools all in one place
98
What are some examples of IDEs in programming languages? (3 marks)
Visual Studio (C#) Eclipse (Java) IDLE (Python)
99
What is a code editor? (2 marks)
The code editor is a text edit area that allows developers to write, edit and save a document of code.
100
What is an example of a visual code editor? (1 mark)
Syntax highlighting
101
What are runtime errors? (2 marks)
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
What is a common cause of runtime errors? (2 marks)
Running out of memory - because instructions have been written in the wrong order.
103
Why use error diagnostics? (2 mark)
Error diagnostics help a programmer to find where they have made a mistake
104
What are some examples of error diagnostics? (3 marks)
Inline syntax highlighting Debug mode Line numbers
105
What are line numbers? (3 marks)
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
What is syntax highlighting? (3 marks)
Syntax highlighting is where the colour of the text changes to show different parts of the program. Errors are also highlighted/underlined.
107
What is a method of debugging code? (1 mark)
Breakpoints
108
What is variable watching? (2 marks)
Variable watching is the process of inspecting the value of a variable while the program is executing in debug mode
109
What are breakpoints? (1 mark)
A point in the program where the code will stop executing.
110
Why are breakpoints set? (2 marks)
Breakpoints are set by the programmer so that the IDE stops the program mid-way through running
111
What do breakpoints allow a programmer to do? (2 marks)
Step through the code line by line | They can watch variables as they change
112
What is the purpose of stepping? (2 mark)
It executes the code one line at a time to check for errors.
113
What is a runtime environment? (1 marks)
Allows the programmer to test their program while it is running
114
What are some examples of code editors? (3 marks)
Auto-completion Syntax checks Bracket matching
115
What does a runtime environment allow the programmer to do? (2 marks)
Execute the program line by line and give useful information to the programmer if the program was to crash
116
What is auto-completion? (2 marks)
As you start to type the first part of a function, it suggests or completes the function and any arguments or variables
117
What is bracket matching? (2 marks)
It uses pairs of brackets to mark out blocks of code- which allows the code to be read and understood more quickly.
118
What are syntax checks? (2 marks)
This recognises incorrect use of syntax and highlights any errors
119
What are some examples of IDEs? (6 marks)
``` Translator Build automation Debugging tools Run-time environment Syntax highlighting Auto documentation ```
120
What does the runtime environment allow the programmer to access? (1 mark)
The libraries that come with the programming language
121
What does auto-documentation do? (2 marks)
This explains the function and purpose of the code
122
What is build automation? (2 marks)
These tools save time by automatically doing the processes that would otherwise be done by hand (e.g. testing or compiling)
123
What are importing libraries? (2 marks)
Importing libraries provide functions that are not included in the core part of the programming language
124
What are constants? (2 marks)
Data values that stay the same every time a program is executed
125
What is the purpose of optimisation? (1 mark)
To make your code more efficient
126
Why do computers use binary? (1 mark)
So that computers can be based on logic circuits
127
What is the name of the electrical components that are contained in the CPU, consisting in one of two states (on/off)?
Transistor
128
What are the features of a low level language
Runs quickly Requires less RAM can manipulate hardware Processor-specific has to be translated into machine code
129
What is the relationship between transistors, logic gates and logic circuits? (2 marks)
Logic gates are made of transistors. | Logic circuits are made of logic gates.