01 / Boolean logic, languages and IDEsEvery board
Which logic gate gives an output of 1 only when both inputs are 1?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: B AND
An AND gate outputs 1 (True) only if input A and input B are both 1. If either input is 0, the output is 0.
Checked against ocr.org.uk
02 / Boolean logic, languages and IDEsEvery board
Which logic gate gives an output of 1 when at least one input is 1?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: A OR
An OR gate outputs 1 if A is 1, B is 1, or both are 1. It only outputs 0 when both inputs are 0.
Checked against ocr.org.uk
03 / Boolean logic, languages and IDEsEvery board
What does a NOT gate do?
- AIt outputs 1 when both inputs are 1
- BIt outputs 1 when either input is 1
- CIt reverses its single input
- DIt always outputs 0
Show the answer
Answer: C It reverses its single input
A NOT gate has one input and flips it: 1 becomes 0 and 0 becomes 1. It is also called negation.
Checked against ocr.org.uk
04 / Boolean logic, languages and IDEsEvery board
A burglar alarm sounds when the alarm is switched on and a door is opened.
Which logic gate matches this rule?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: B AND
Both conditions must be true at the same time for the alarm to sound, so the rule is ON AND DOOR. Words like “both” or “and” in a scenario usually point to an AND gate.
Checked against ocr.org.uk
05 / Boolean logic, languages and IDEsEvery board
A shop door opens if a customer steps on the mat or a member of staff presses a button.
Which logic gate matches this rule?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: A OR
Either condition on its own is enough to open the door, and both together still open it. That is how an OR gate behaves: the output is 1 when at least one input is 1.
Checked against ocr.org.uk
06 / Boolean logic, languages and IDEsEvery board
A car beeps when the engine is on (E) and the seatbelt is not fastened (S).
Which expression matches the rule?
- AE OR NOT S
- BNOT (E AND S)
- CNOT E AND S
- DE AND NOT S
Show the answer
Answer: D E AND NOT S
The beep needs two things at once: the engine on (E) and the seatbelt not fastened (NOT S). Joining them with AND gives E AND NOT S. Turn each part of a scenario into a condition, then join them.
Checked against ocr.org.uk
07 / Boolean logic, languages and IDEsEvery board
A heater should turn on when the room is not warm. W is 1 when the room is warm.
Which expression turns the heater on?
- AW
- BW OR W
- CW AND W
- DNOT W
Show the answer
Answer: D NOT W
The heater should be on when W is 0 and off when W is 1. A NOT gate flips W, so NOT W gives exactly that. W AND W and W OR W both just equal W.
Checked against ocr.org.uk
08 / Boolean logic, languages and IDEsEvery board
What does a truth table show?
- AThe output for every possible combination of inputs
- BThe data types of each variable
- CThe steps of a sorting algorithm
- DThe value of every variable at each step as an algorithm runs
Show the answer
Answer: A The output for every possible combination of inputs
A truth table lists every combination of input values with the output for each, using 1 for True and 0 for False. It shows exactly how a gate or circuit behaves.
Checked against ocr.org.uk
09 / Boolean logic, languages and IDEsEvery board
How many rows of input combinations does a truth table with two inputs have?
- A2
- B3
- C4
- D6
Show the answer
Answer: C 4
Each extra input doubles the number of combinations: 2 inputs give 4 rows and 3 inputs give 8. Listing them in counting order (000, 001, 010 and so on) makes sure none is missed.
Checked against cdn.sanity.io
10 / Boolean logic, languages and IDEsAQA, OCR and Eduqas
In logic diagrams, which gate is drawn as a triangle with a small circle at its tip?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: C NOT
The NOT symbol is a triangle with a small circle on its output; leaving the circle off, or adding one to AND or OR, is a common mistake. AND has a flat back and a D-shaped front, and OR has a curved back and a pointed front.
Checked against ocr.org.uk
11 / Boolean logic, languages and IDEsAQA and Eduqas
When does an XOR gate output 1?
- AWhen its two inputs are different
- BWhen its two inputs are the same
- CWhen both inputs are 0
- DWhen both inputs are 1
Show the answer
Answer: A When its two inputs are different
XOR (exclusive OR) outputs 1 when exactly one input is 1, so the inputs differ. Unlike OR, it outputs 0 when both inputs are 1.
Checked against cdn.sanity.io
12 / Boolean logic, languages and IDEsAQA and Eduqas
In the Boolean expression A . B, what does the dot mean?
- AOR
- BAND
- CNOT
- DXOR
Show the answer
Answer: B AND
In Boolean expressions a dot means AND, a plus means OR, a bar over a term means NOT and ⊕ means XOR. AQA expects these symbols rather than words, and Eduqas uses the same ones.
Checked against cdn.sanity.io
13 / Boolean logic, languages and IDEsEduqas
In Boolean algebra, what does A . 1 simplify to?
- A0
- B1
- CA
- DNOT A
Show the answer
Answer: C A
ANDing with 1 leaves A unchanged (the identity rule), while ORing with 1 always gives 1, whatever A is (annulment). Eduqas pupils use rules like these to simplify expressions.
Checked against eduqas.co.uk
14 / Boolean logic, languages and IDEsEduqas
In Boolean algebra, what does A AND NOT A always equal?
- A0
- B1
- CA
- DNOT A
Show the answer
Answer: A 0
A and NOT A are always opposite, so they can never both be 1: A AND NOT A is always 0. One of them is always 1, so A OR NOT A is always 1. These are the complement rules.
Checked against eduqas.co.uk
15 / Boolean logic, languages and IDEsEvery board
In Python, a condition mixes and with or and has no brackets. Which is worked out first?
- AWhichever comes first, reading left to right
- Bor
- Cand
- DWhichever comes last
Show the answer
Answer: C and
In Python, and is applied before or, just as multiplication comes before addition. So a or b and c means a or (b and c). Adding brackets makes the meaning clear to anyone reading the code.
Checked against docs.python.org
16 / Boolean logic, languages and IDEsEvery board
What is a logic circuit?
- AA loop that repeats a logical test
- BA table that lists every possible combination of inputs and outputs
- CLogic gates joined so some outputs feed other inputs
- DA cable that links two computers
Show the answer
Answer: C Logic gates joined so some outputs feed other inputs
A logic circuit combines gates, with the output of one gate becoming an input to another. Each circuit matches a Boolean expression, such as (A AND B) OR NOT C, and its behaviour can be shown in a truth table.
Checked against ocr.org.uk
17 / Boolean logic, languages and IDEsEvery board
Which is a feature of a high-level language?
- AEach instruction matches one machine code instruction
- BIt uses English-like words and must be translated
- CIt is written as binary 1s and 0s
- DThe processor can run it with no translation
Show the answer
Answer: B It uses English-like words and must be translated
High-level languages such as Python use English-like keywords, so they are easier to read, write and debug. One line can stand for many machine code instructions, and the code must be translated before the processor can run it.
Checked against cdn.sanity.io
18 / Boolean logic, languages and IDEsEvery board
Why is most software written in high-level languages?
- AIt always runs faster than machine code
- BIt never needs translating
- CIt is quicker to write, read and debug
- DIt gives direct control of each register
Show the answer
Answer: C It is quicker to write, read and debug
High-level code is easier for people to work with and is portable: it can be translated for different processors. Low-level code gives more control and can be faster, but it is harder to write and tied to one processor family.
Checked against cdn.sanity.io
19 / Boolean logic, languages and IDEsEvery board
What is machine code?
- APseudocode written on paper
- BShort words such as ADD and SUB
- CBinary instructions the processor runs directly
- DEnglish-like code that must be compiled
Show the answer
Answer: C Binary instructions the processor runs directly
Machine code is the binary that a processor actually executes, so it needs no translating. Each type of processor has its own instruction set, so machine code for one may not run on another.
Checked against cdn.sanity.io
20 / Boolean logic, languages and IDEsEvery board
Low-level code written with short codes such as ADD and SUB is called:
- Aassembly language
- Bmachine code
- Ca high-level language
- Dpseudocode
Show the answer
Answer: A assembly language
Assembly language uses mnemonics, short memorable codes like ADD, in place of binary. Each assembly instruction matches one machine code instruction, so it is still low level and still has to be translated.
Checked against cdn.sanity.io
21 / Boolean logic, languages and IDEsEvery board
When might a programmer choose a low-level language?
- ATo control specific hardware in an embedded system
- BTo make the code easy for beginners to read and change
- CTo make the code run on any processor
- DTo write a large app quickly
Show the answer
Answer: A To control specific hardware in an embedded system
Low-level code gives direct control of the processor and memory, and can be small and fast. That suits embedded systems, device drivers and other code that controls specific hardware.
Checked against cdn.sanity.io
22 / Boolean logic, languages and IDEsEvery board
Why must code in a high-level language be translated?
- ATo make the code easier to read
- BTo check that input is sensible
- CThe processor can only run machine code
- DTo add comments to the code
Show the answer
Answer: C The processor can only run machine code
A processor understands only machine code. Translators turn source code into machine code it can execute. Assembly language and high-level code must be translated; machine code itself needs no translation.
Checked against cdn.sanity.io
23 / Boolean logic, languages and IDEsEvery board
Which is a feature of a compiler?
- AIt translates the whole code into an executable file
- BIt stops at the very first error it finds while the code is running
- CIt translates and runs one line at a time
- DIt must be present every time the code runs
Show the answer
Answer: A It translates the whole code into an executable file
A compiler translates all the source code in one go into an executable file, listing any errors at the end. The executable runs quickly, and users need neither the source code nor the compiler, which also keeps the code private.
Checked against ocr.org.uk
24 / Boolean logic, languages and IDEsEvery board
Which is a feature of an interpreter?
- AIt translates and runs the code one line at a time
- BIt translates all of the code at once before any of it can run
- CIt turns assembly language into machine code
- DIt produces an executable file to share
Show the answer
Answer: A It translates and runs the code one line at a time
An interpreter translates and runs code line by line, stopping when it reaches an error, which makes testing and debugging easy. But the code runs more slowly, and the interpreter is needed every time it runs.
Checked against ocr.org.uk
25 / Boolean logic, languages and IDEsEvery board
Put these steps in order for code that is compiled.
- AThe compiler translates all of the code
- BAn executable file is produced
- CThe programmer writes the source code
- DThe user runs the executable
Show the answer
The right order:
- The programmer writes the source code
- The compiler translates all of the code
- An executable file is produced
- The user runs the executable
The programmer writes source code, the compiler translates all of it and produces an executable file, and users then run that executable. They need neither the compiler nor the source code.
Checked against ocr.org.uk
26 / Boolean logic, languages and IDEsEvery board
A games company wants to sell its game without letting buyers see the source code. Which translator suits this?
- AAn interpreter
- BA web browser
- CA text editor
- DA compiler
Show the answer
Answer: D A compiler
A compiler produces an executable that buyers can run without the source code, which protects the company’s work. With an interpreter, buyers would need both the source code and the interpreter.
Checked against ocr.org.uk
27 / Boolean logic, languages and IDEsAQA and Eduqas
Which translator turns assembly language into machine code?
- AA debugger
- BAn interpreter
- CAn assembler
- DA compiler
Show the answer
Answer: C An assembler
An assembler translates assembly language into machine code. Because assembly has a one-to-one match with machine code, each assembly instruction becomes one machine code instruction.
Checked against cdn.sanity.io
28 / Boolean logic, languages and IDEsOCR and Eduqas
What is an IDE?
- AA set of tools for writing and testing code
- BA list of a language’s keywords
- CA cable that connects a hard drive
- DA type of high-level language used for websites
Show the answer
Answer: A A set of tools for writing and testing code
An integrated development environment brings the tools a programmer needs into one place: an editor, error diagnostics, a run-time environment and a translator, plus debugging tools.
Checked against ocr.org.uk
29 / Boolean logic, languages and IDEsOCR and Eduqas
Colouring keywords, auto-indenting and suggesting the rest of a word are features of which IDE tool?
- AThe translator
- BThe editor
- CThe run-time environment
- DThe firewall
Show the answer
Answer: B The editor
The editor is where code is typed. Features such as syntax highlighting, automatic indentation, line numbers and auto-complete make code easier to read and help avoid mistakes.
Checked against ocr.org.uk
30 / Boolean logic, languages and IDEsOCR and Eduqas
Which IDE feature points out mistakes in the code and explains them with messages?
- AError diagnostics
- BAuto-complete
- CThe run-time environment
- DLine numbering
Show the answer
Answer: A Error diagnostics
Error diagnostics point out errors, often underlining the line and giving a message, such as a missing bracket. This helps the programmer find and fix errors quickly.
Checked against ocr.org.uk
31 / Boolean logic, languages and IDEsOCR
Which IDE tool lets the programmer run the code inside the IDE and see its output?
- AError diagnostics
- BThe editor
- CAuto-indentation
- DThe run-time environment
Show the answer
Answer: D The run-time environment
The run-time environment lets code be run and tested without leaving the IDE, showing its output and any errors that happen while it runs.
Checked against ocr.org.uk
32 / Boolean logic, languages and IDEsEduqas
A programmer wants the code to pause at line 20 so they can inspect it. Which tool should they use?
- AAuto-complete
- BA variable watch
- CA breakpoint
- DSyntax highlighting
Show the answer
Answer: C A breakpoint
Debugging tools help find logic errors. A breakpoint pauses the code at a chosen line, stepping runs it one line at a time, and a variable watch shows how chosen variables change, like a live trace table.
Checked against eduqas.co.uk
33 / Boolean logic, languages and IDEsEduqas
Which stage of compilation breaks the source code into tokens and removes comments and spaces?
- ACode generation
- BLexical analysis
- CSemantic analysis
- DSyntax analysis
Show the answer
Answer: B Lexical analysis
Lexical analysis splits the source code into tokens and removes comments and white space. Syntax analysis checks the tokens follow the rules of the language, semantic analysis checks the meaning makes sense, and code generation produces machine code, which can then be optimised.
Checked against eduqas.co.uk
34 / Boolean logic, languages and IDEsEvery board
Which translator is usually better when a beginner is testing small pieces of code?
- AAn interpreter
- BA defragmenter
- CA compiler that is run only at the end
- DA firewall
Show the answer
Answer: A An interpreter
An interpreter runs code straight away, line by line, and stops at the line with the error, so a beginner sees results and problems at once. A compiler suits finished software that is shared with users.
Checked against ocr.org.uk