Logic and Languages Flashcards
What does the arithmetic operator ‘modulus’ do? Give an example.
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.
What does the arithmetic operator ‘floor division’ do? Give an example.
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.
What does the arithmetic operator ‘exponentiation’ do? Give an example.
It calculates the power of a number. For example 7**2 = 49
What is the python and pseudocode symbol for ‘modulus’?
16 MOD 3 (pseudocode)
16 % 3 (python)
What is the python and pseudocode symbol for ‘floor division’?
16 DIV 3 (pseudocode)
16 // 3 (python)
What is the python and pseudocode symbol for ‘exponentiation’?
7^2 (pseudocode)
7**2 (python)
What can logic statements be evaluated to? (1 mark)
True (1) or False (0)
What are the types of Boolean operators?
AND, OR & NOT
What is a truth table? (2 marks)
A truth table is a method of representing every possible output based on the inputs to a Boolean expression.
What is NOT also know as?
Negation
What is OR also known as?
Disjunction
What does the OR operator return?
The operator returns true if either of the conditions are true. It only returns false if both conditions are false.
What does the NOT operator do?
Takes one input an reverses it
What does the AND operator do?
Only returns true if both conditions are true, else it returns false.
What is the order of precedence?
NOT, then AND, then OR
How do you find out the number of rows on your truth table? (1 mark)
Do 2 (base) to the power of n (the number of inputs) E.g. 2^3 = 8 rows
What do comparison operators do? (1 mark)
Evaluate to a Boolean value
What do Boolean operators do? (2 marks)
Take Boolean inputs and evaluate to a Boolean value
What are the two types of testing? (2 marks)
Iterative testing
Final testing/terminal testing
What is iterative testing? (2 marks)
Iterative testing tests modules and parts of a program as the program is developed
What is final/terminal testing? (2 marks)
Final testing (also known as terminal testing) tests the whole program at the end of production
What is the purpose of testing? (2 marks)
To find errors and determine (then patch) vulnerabilities so the program functions as intended
What are the two types of errors? (2 marks)
Syntax error
Logic error
What is the syntax of a language? (1 mark)
It is the collection of rules that form its structure
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
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
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.
What does a test plan test for? (3 marks)
Boundary/extreme data
Erroneous/invalid data
Normal/typical data
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
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.
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”
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
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.
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
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
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.
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
What are the types of validation checks?
Range check Type check Length check Presence check Format check
What is a range check? (2 marks)
A number or date is within a sensible/allowed range
What is a type check? (2 marks)
Data is of the right type, such as integer, letter or text
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
What is a presence check? (2 marks)
Checks that data has been entered, i.e. the field has not been left blank
What is a format check? (2 marks)
Checks that the format of, for example, a postcode or email address is correct
What is authentication? (2 marks)
Authentication – entering data twice or checking from an alternative source
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
What is the purpose of authentication routines? (2 marks)
Authentication routines are used to make sure a person is who they claim to be
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.
What are the types of data sanitisation? (2 marks)
Masking
Input sanitisation
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
What is masking? (1 mark)
Hiding visible data
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