Logic and Languages Flashcards
(129 cards)
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