wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Logic && Boolean Expressions (A-Level Computer Science)

Total questions: 58

Worksheet time: 1hrs 18mins

Name
Class
Date
1.

Which numbers would cause the Boolean expression "variable=<14" to be true?

a)

3,17,20

b)

14,18,20

c)

1,11,14

d)

13,14,15

2.

Where can Boolean expressions be found?

a)

In a sprite

b)

By itself

c)

In an if-statement

d)

In a variable

3.

What is a Conditional Statement?

a)

A part of the code that allows you to perform different actions depending on which is true or false

b)

A variable that has a value of true or false

c)

A part of the code that tells you if a value is less than another value

d)

A part of the code that tests whether or not two values are equal

4.

Is "3" == 3 True?

a)

Yes, same number

b)

No, One is in quotes.

5.

How many values does a Boolean variable have?

a)

4

b)

3

c)

2

d)

1

e)

Infinite

6.

What is this expression?

a)

equal to

b)

greater than or equal to

c)

less than

d)

is not equal to

7.

What is this expression?

a)

equal to

b)

greater than

c)

less than

d)

is not equal to

8.

What type of logic is this table showing:

a)

AND

b)

OR

c)

NOT

d)

NOR

9.

What type of logic is this table showing:

a)

AND

b)

OR

c)

NOT

d)

XOR

10.

Use the logic condition to find the value of W:


A & ~(B | C)

a)

True

b)

False

11.

Use the logic condition to find the value of Y:


(A (+) B) | C

a)

True

b)

False

12.

What is expression that would represent this Boolean Gate Diagram?

a)

~(A & B) | (C & D)

b)

(A & B) | (C & D)

c)

(A & B) | ~(C & D)

d)

(A & B) | ~(C | D)

13.

What is expression that would represent this Boolean Gate Diagram?

a)

~A & ~(B (+) C)

b)

~A & (B (+) C)

c)

~A & ~(B | C)

d)

A & (B (+) C)

14.

If the input values are A = 1, B = 0, C = 1, what would be the result at output D and G, respectively?

a)

Output D = 0, Output G = 0

b)

Output D = 0, Output G = 1

c)

Output D = 1, Output G = 0

d)

Output D = 1, Output G = 1

15.

Commutative Law states that..

a)

Expressions can be simplified by removing like terms

b)

The order of variables in an operation does not matter

c)

Expressions can be factorised, or multiplied out

d)

A variable AND itself is the same as the variable.

16.

Which of the following are correct expressions of De Morgan's Theorum?

a)

¬A.¬B = ¬(A.B)

b)

¬A.B = ¬B+A

c)

¬(A.B) = ¬A+¬B

d)

A.B = ¬(¬A+¬B)

e)

A+B = ¬A.¬B

17.

Which law tells us that we can factorise or multiply out expressions?

a)

Associative law

b)

Distributive law

c)

De Morgan's law

d)

Commutative law

18.

Absorptive Law states that..

a)

Expressions can be simplified by removing like terms

b)

The order of variables in an operation does not matter

c)

Expressions can be factorised, or multiplied out

d)

A variable AND itself is the same as the variable.

19.

Which law states that AND and OR can replace each other in the right circumstances?

a)

De Morgan's Law

b)

Associative Law

c)

Distributive Law

d)

Cole's Law

e)

Identity

20.

Truth table for AND gate?

a)
b)
c)
d)
21.

Truth table for OR gate?

a)
b)
c)
d)
22.

Which logic gate is this truth table for?

a)

AND

b)

OR

c)

NOR

d)

XOR

23.

Which of these programming constructs make use of Boolean logic?

a)

if ... then ...

b)

while ... do ....

c)

repeat ... until ....

d)

repeat n times ....

24.

If x = 3 and y = 5, choose all the statements that evaluate to True.

a)

x < y

b)

y > x**2

c)

2 * x == y

d)

y % x == 2

25.

If a = 10 and b = 5 which of these Boolean expressions are True?

a)

a > b And a == 2 * b

b)

b > a And b == a / 3

c)

a < b And b = a / 2

d)

a == 2 * b And a**2 == b*20

26.

Which word best completes this sentence:


Data that is Boolean can only take two values: True _____ False.

a)

and

b)

or

c)

not

27.

Which word best completes this sentence:


A logic gate is a tiny electronic component on a chip that has inputs and ______ to simulate a Boolean operation.

a)

output

b)

result

c)

data

d)

processing

28.

Which word best completes this sentence?


A combination of logic gates is known as a logic _______.

a)

circuit

b)

program

c)

array

d)

truth table

29.

Select all equivalent expressions

a)

Q is A or B

b)

Q = A + B

c)

Q is A and B

d)

Q = A·B

30.

Select all equivalent expressions

a)

Q is A or B

b)

Q = A V B

c)

Q is A and B

d)

Q = A ^ B

31.

Select all equivalent expressions

a)

Q = ¬A^¬B

b)

Q = ¬(A+B)

c)

Q = ¬(A.B)

d)

Q is not A or not B

e)

Q is not A and not B

32.

Select all equivalent expressions

a)

Q = A V B

b)

Q = A ^ B

c)

Q is A or B

d)

Q is A and B

33.

Select all equivalent expressions

a)

Q is neither A nor B

b)

Q is not A or B

c)

Q = ¬B + ¬A

d)

Q = ¬A.¬B

e)

Q = ¬(A+B)

34.

Which law states that AND and OR can replace each other in the right circumstances?

a)

De Morgan's Law

b)

Associative Law

c)

Distributive Law

d)

Cole's Law

e)

Identity

35.

Which of the following are correct expressions of De Morgan's Theorum?

a)

¬A.¬B = ¬(A.B)

b)

¬A.B = ¬B+A

c)

¬(A.B) = ¬A+¬B

d)

A.B = ¬(¬A+¬B)

e)

A+B = ¬A.¬B

36.

Commutative Law states that..

a)

Expressions can be simplified by removing like terms

b)

The order of variables in an operation does not matter

c)

Expressions can be factorised, or multiplied out

d)

A variable AND itself is the same as the variable.

37.

Why might one most likely use a Boolean expression?

a)

To loop a set amount of code

b)

To activate a response with either true or false

c)

To locate a bug in the code

d)

To make a sprite appear

38.

Which numbers would cause the Boolean expression "variable<=14" to be true?

a)

3,17,20

b)

14,18,20

c)

1,11,14

d)

13,14,15

39.

A Boolean expression...

a)

Fixes any errors in the line of code

b)

Sets everything in it equal to each other

c)

Checks if something is true or false

d)

Loops the program to continue infinitely

40.

Which of the following is the correct truth table for the Boolean expression shown here:

a)
b)
c)
d)
41.

The two variables age and day are initialized with the values shown.

age <-- 16

day <-- "Monday"

Choose the compound conditional that evaluates to false.

a)

( (age = 16) AND ( NOT (day = "Tuesday") ) ) AND (day = "Monday")

b)

( (age = 16) AND (day = "Tuesday") ) OR (day = "Monday")

c)

( (age > 10) AND ( (age + 5) > 25 ) )

d)

NOT ( (age = 16) AND (day = "Tuesday") )

42.

This program uses a nested conditional to recommend a heat level for cooking eggs.


In which situations will heatLevel be "medium"?


Note that there may be multiple answers to this question. Choose all answers that apply:

a)

When inHurry is false and eggDish is "fried"

b)

When inHurry is true and eggDish is "fried"

c)

When inHurry is false and eggDish is "scrambled"

d)

When inHurry is true and eggDish is "scrambled"

43.

Trace the code and plot the movements of the robot for the 3 scenarios.

If the robot is directed to move onto a black square, it “crashes” and the program ends.


Choose the scenario that results in a "crash."

a)
b)
c)
44.

In the program below, the initial value of x is 5 and the initial value of y is 10.


What is displayed as a result of running the program?

a)

Foxtrot

b)

Hotel

c)

November

d)

Yankee

45.

The diagram shows a circuit composed of two logic gates labeled OR and AND. Each gate takes two inputs and produces a single output.


If the inputs A and C are both false, which of the following best describes the output of the AND gate?

a)

The output will be true no matter what the value of input B is.

b)

The output will be false no matter what the value of input B is.

c)

The output will be true if input B is true; otherwise it will be false.

d)

The output will be false if input B is true; otherwise it will be true.

46.
 Evaluate (to true or false) each of the following expressions:
14 >= 14
15 > 15
16 != 16
18 >= 19
a)
T, F, F, F
b)
T, T, T, T
c)
F, T, F, F
d)
F, T, T, F
47.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
48.
What will be the output?
name = 'Dave'
greeting = "Good morning" + name
print (greeting)
a)
Good morning 'Dave'
b)
Good morning Dave
c)
Good morning name
d)
Good morning + Dave
49.

What is this logic circuit called?

a)

Half Adder

b)

Full Adder

c)

And Adder

d)

Ripple Carry Adder

e)

Or Adder

50.

Which logic circuit is a Half Adder?

a)
b)
c)
d)
e)
51.

Which circuit would add two 4-bit numbers?

a)
b)
c)
d)
e)
52.

Which logical operator does this Venn Diagram represent? (Red is True, A is the left circle)

a)

NOT

b)

AND

c)

OR

d)

XOR

e)

NAND

53.

Which logical operator does this Venn Diagram represent? (Red is True, A is the left circle)

a)

NOT(A)

b)

A AND B

c)

A OR B

d)

A XOR B

e)

A NAND B

54.

Which Boolean expression(s) does this Venn Diagram represent? (Red is True, A is the left circle)

a)

NOT(B)

b)

NOT(A) AND B

c)

NOT(A) OR B

d)

(A XOR B) AND B

e)

A NAND (A NOR B)

55.

Which logical operator does this Venn Diagram represent? (Red is True)

a)

¬

b)

c)

d)

56.

Which logical operator does this Venn Diagram represent? (Red is True, A is the left circle)

a)

¬

b)

c)

d)

57.

For this clocked logic signal, what are the correct labels for A and B?

a)

A = Falling edge. B = Rising edge.

b)

A = Rising edge. B = Falling edge.

58.

What is the name of the device shown?

a)

Full Adder

b)

Clock

c)

Half Adder

d)

D-Type Flip Flop

e)

CPU