wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Year 8 CS Quiz

Total questions: 120

Worksheet time: 1hrs 18mins

Name
Class
Date
1.

1)Which of the following characters is used to give single-line comments in Python?



a)

a)//

b)

b) #

c)

c) !

d)

d) /*

2.

2)What data type will be displayed from the code { print(type(10))?



a)

a) Float

b)

b) string 

c)

c) int 

d)

d) boolean

3.

3)A_____ in python that is used to define numbers. 



a)

a) Integer 

b)

b) Boolean 

c)

c) Float

d)

d) String

4.

4)A _____ in Python is used to define numbers with decimals.



a)

a)Boolean 

b)

b)Float 

c)

c)String 

d)

d)Integer

5.

5)What programming language uses the following logo?


a)

a) HTML


b)

b)Python

c)

c)Java 

d)

d)CSS

6.

6)Which of the following is the correct extension of the Python file?



a)

a) .python 

b)

b) .pl 

c)

c) .py 

d)

d) .p

7.

7)What data type is the object below?


L = [1, 23, 'hello', 1]



a)

a)  list 

b)

b) dictionary

c)

c) array 

d)

d) tuple

8.

8)An algorithm can be defined as . . .



a)

a) deciding which statement is true 

b)

b)repeating the same code several times

c)

c)a set of steps to complete a task

d)

d)representing data as zeros and ones (0 & 1)

9.

9)A method of focusing on what is important first . . .



a)

a)Pattern recognition

b)

b)Decomposition

c)

c)Algorithm

d)

d)Abstraction

10.

10)The IPO model explains how the computer works. It stands for Input, Processing and ___________



a)

a)Outburst

b)

b)Output

c)

c)Outback

d)

d)Outside

11.

12)Complete the following coding segment:

name = "Hamed"

_______("Welcome ", name)


a)

a) Print

b)

b) Input

c)

c) Type

d)

d) Def 

12.

13)Which of the following statements assigns the value 25 to the variable x in Python?


a)

a)x ← 25 

b)

b)x = 25 

c)

c)x := 25

d)

d)int x = 25

13.

14)How can we get 6 from the given list? 

list=[9,5,6,3]


a)

a)list[2]

b)

b)list[3]

c)

c)list[0]

d)

d)list[-3]

14.

15)What will the result be of the following Python code:

teams=["Brazil", "France", "England", "Argentina"]

teams.sort()

print(teams)


a)

a)["Argentina", "Brazil", "England", "France"]

b)

b)["Brazil", "France", "England", Argentina"]

c)

c)["Brazil", "France", "England"]

d)

d)["England", "France", "Argentina", "Brazil"]

15.

16)Read the Python program below:

print("What’s your favorite programming language?")

language = input()

if language != "Python":

    print("You should try a little Python too")

else:

    print("Hello Pythonista") 

When this program is executed?


a)

a)Hello Pythonista

b)

b)You should try a little Python too Hello Pythonista

c)

c)Hello Pythonista You should try a little Python too

d)

d)You should try a little Python too

16.

a = 13

b = a + 1 

a = 42

print(b)

17) When this program is run, what will be displayed on the screen?



a)

a)14

b)

b)43

c)

c)There is an error in the program because variable b cannot hold two values at the same time

d)

d)14 43

17.

18)Read the Python program below:


a = 13

print(2*a)

print(a)


When this program is run, what will be displayed on the screen?



a)

a)13 26

b)

b)Line 3 will not be executed 

c)

c)13

d)

d)26

18.

19)What does this diagram represent?

a)

a) graph

b)

b) flowchart

c)

c) organization structure

d)

d) flow

19.

Convert the following binary value into denary

0 0 0 1 1 0 1 1

(a)  

20.

Convert the following binary value into denary

1 1 1 0 0 1 1 0

(a)  

21.

Convert denary 87 to binary

(a)  

22.

Denary 37 to Hex

(a)  

23.

Denary 59 to Hex

(a)  

24.

Hex 2F to Denary

(a)  

25.

Hex 1A to Binary

(a)  

26.

Hex 16 to Binary

(a)  

27.

Binary 0011 0111 to Hex

(a)  

28.

Binary 1101 1111 to Hex

(a)  

29.

The binary number 1110 0100 is an even number.

Explain why this is the case with reference to the rightmost bit.

a)

The rightmost bit shows the 1s column. If it is 0, then the number is even. If it is 1, then the number is odd.

b)

The rightmost bit shows the 1s column. If it is 0, then the number is even. If it is 1, then the number is even.

c)

The rightmost bit shows the 2s column. If it is 0, then the number is even. If it is 1, then the number is odd.

30.

An error occurs when you try to add 11011001 to 11100100 and store it as an 8-bit number.
Explain the error that occurs using one word starting with 'O'.


(a)  

31.

Which is the best answer to explain why computers use binary.

a)

Computers use circuits and logic gates. 1 or 0 represents on and off, which is true or false.

b)

Computers understand binary easier than human language so it can compile code faster.

c)

Computers have 8 states which are the bit values of binary to work out numbers.

d)

Computers use true or false statements and that is what 1 and 0 is.

32.

How many bits are there in a Nibble? (Just give the number)

(a)  

33.

How many bits are there in a byte? (Just give the number)

(a)  

34.

How many bytes are there in a kibibyte? (Just give the number)

(a)  

35.

Which of these lists show the correct order for data storage capacities?

a)

bit

nibble

byte

kibibyte

mebibyte

gibibyte

b)

bit

nibble

mebibyte

byte

kibibyte

gibibyte

c)

byte

kibibyte

gibibyte

bit

nibble

mebibyte

d)

kibibyte

mebibyte

gibibyte

bit

nibble

byte

36.
What is the output of an OR gate if the inputs are 1 and 0?
a)
0
b)
1
c)
OFF
d)
2
37.
What is the output of an AND gate if the inputs are 1 and 0?
a)
ON
b)
2
c)
1
d)
0
38.
What is the output of a NOT gate if the inputs is 0?
a)
1
b)
0
c)
OFF
d)
2
39.
A NOT gate has…
a)
Two inputs and one output
b)
One input and one output
c)
One input and two outputs
d)
Two inputs and two outputs
40.
An OR gate has
a)
Two inputs and one output
b)
One input and one output
c)
One input and two outputs
d)
Two inputs and two outputs
41.
The output of any logic gate can have either of two _________ ?
a)
Gates
b)
States
c)
Inputs
d)
Outputs
42.
A logic state can only be….
a)
On or 1
b)
Off or 1
c)
1 or 0
d)
In and Out
43.
The output of a ________ gate is only 1 when both inputs are 1.
a)
OR
b)
NOT
c)
NAND
d)
AND
44.
What logic gate is this?
a)
AND
b)
OR 
c)
NOT
d)
TO
45.
What gate is this table for?
a)
AND
b)
OR
c)
NOT
d)
NOR
46.
What gate is this truth table for?
a)
AND
b)
OR
c)
NOT
d)
THE 
47.
What gate is this table for?
a)
AND
b)
XOR
c)
OR 
d)
NOT
48.

Which logic gate is this?

a)

AND

b)

OR

c)

XOR

d)

NOT

49.
What logic gate is this?
a)
AND 
b)
OR 
c)
NOT 
d)
THE
50.

A truth table lists every possible combination of input and the resulting output

a)

True

b)

False

51.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
52.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
53.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
54.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
55.
What output will this code produce?
a)
3
b)
20
c)
25
d)
17
56.
What output will this code produce?
a)
1
b)
3
c)
2
d)
4
57.
What output will this code produce?
a)
1
b)
3
c)
i
d)
0
58.

word = "amazing"


For the given string if we run word[2:5] , what would the result be?

a)

mazi

b)

mazin

c)

azi

d)

azin

59.

Which of the following is not a valid string function?

a)

isalphanumeric

b)

isspace

c)

islower

d)

isalnum

60.

string="HELlo"

What will be the result of string.isupper()?

(a)  

61.

What is printed by the following statement?

print("P" not in "APCSP")

a)

True

b)

False

c)

Error

62.

What is printed by the following statement?

print("A" in "APCSP")

a)

True

b)

False

c)

Error

63.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

64.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

65.

Which operator returns True if target string is somewhere in the search string; otherwise it returns False.

a)

==

b)

!=

c)

in

d)

is

66.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

\l

b)

/

c)

\\n

d)

\n

67.

Which is the most appropriate data type for: "13th December"

a)

Float

b)

Boolean

c)

Integer

d)

String

68.

What will the output be from the following code?

print("Hello world!" * 2)

a)

TypeError

b)

Hello world world!

c)

Hello world!Hello world!

d)

Hello world! * 2

69.

What will the output be from the following code?

print("Hello world!\nHello world!")

a)

Hello world! Hello world!

b)

Hello world!

Hello world!

c)

SyntaxError

d)

Hello world!

70.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

71.

print("12"*3)

What would this print?

a)

121212

b)

36

c)

24

d)

12*3

72.

A variable is a named value that can be changed in the program.

a)

False

b)

True

73.

What is a String?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

74.

Which value is a String?

a)

64

b)

"cat"

c)

True

d)

0.5

75.

What is an Integer?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

76.

Which value is an Integer?

a)

64

b)

"cat"

c)

True

d)

0.5

77.

What is a Float?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

78.

Which value is a Float?

a)

64

b)

"cat"

c)

True

d)

0.5

79.

What is a Boolean?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

80.

Which value is a Boolean?

a)

64

b)

"cat"

c)

True

d)

0.5

81.

Which writes a message for the user?

a)

input()

b)

myVar="Hi"

c)

print("Hello!")

d)

max=100

82.

Which of the following is NOT a basic file handling operation?

a)

Read

b)

Write

c)

Open

d)

Execute

83.

What is the purpose of the 'Close' operation in file handling?

a)

To delete the file from the directory

b)

To save changes to the file

c)

To end the file handling session

d)

To copy the file to another location

84.

What is the primary function of a file handler in computer programming?

a)

To display data on the screen

b)

To store the external file in RAM so that the running program can work on it

c)

To manage user inputs

d)

To point to a file with a variable so the program can access it.

85.

What role does a cursor play in file handling?

a)

It encrypts the data being written to a file

b)

It manages the security of a file

c)

It keeps track of the current location within the file when reading or writing

d)

It compresses the file data for storage efficiency

86.

What is the purpose of the 'open()' function in programming?

a)

To close a file

b)

To delete a file

c)

To read from or write to a file

d)

To rename a file

87.

What must be provided to the 'open()' function to successfully open a file?

a)

The file's size

b)

The file's creation date

c)

The file's name including its file extension

d)

The file's read/write speed

88.

What does the 'file handle' refer to in the context of opening a file?

a)

A tool to physically handle the file

b)

A special variable that stores the file's data

c)

A special variable that refers to the opened file

d)

The user interface for managing files

89.

What is the purpose of using '\n' in the write statement when writing to a file in Python?

a)

To indicate the end of the program

b)

To add a new line character

c)

To delete the previous line

d)

To make the text bold

90.

Which method is used to write text to a file in Python?

a)

file.append()

b)

file.read()

c)

file.write()

d)

file.save()

91.

What does the 'readline()' function do when reading a file in Python?

a)

It reads the entire file at once.

b)

It reads the next character in the file.

c)

It reads the current line from the file and then moves the cursor to the next line.

d)

It reads the next line from the file.

92.
Where can Linear Search be performed?
a)
On letters
b)
On numbers
c)
Both
d)
None of these
93.
Which values can Binary Search be performed on?
a)
Letters
b)
Numbers
c)
Ordered Numbers
d)
Ordered Letters
94.
On average, which searching algorithm is more efficient?
a)
Binary Search
b)
Linear Search
95.
Linear Search is faster than Binary search
a)
TRUE
b)
FALSE
c)
It depends on the scenario
96.
How many linear searches will it take to find the value 7 in the list [1,4,8,7,10,28]?
a)
2
b)
3
c)
4
d)
5
97.
Bubble sort takes the first two values of a list, and swaps them if wrong?
a)
True
b)
False
98.
How many binary searches will it take to find the value 7 in the list [1,4,7,8,10,28]?
a)
0
b)
1
c)
2
d)
3
99.
How many binary searches will it take to find the value 10 in the list [1,4,9,10,11]?
a)
0
b)
1
c)
2
d)
3
100.
Which of the following is the best description of the linear search algorithm?
a)
Put the elements in order, then go through them one by one until target is found or the end of the list is reached.
b)
Put the elements in order, compare with the middle value, if not the target: continue to the left or right of the middle and repeat. 
c)
Elements do not need to be in order. Go through them one by one until target is found or the end of the list is reached.
d)
Elements do not need to be in order, compare with the middle value, if not the target: continue to the left or right of the middle and repeat. 
101.
A Linear search algorithm requires data to be ordered.
a)
True
b)
False
102.
What will happen in a Linear search algorithm if no match is found?
a)
It continues to search in a never ending loop.
b)
"Item not found" is returned
103.
A linear search is to be performed on the list:
12   6   8  1  3
How many comparisons would it take to find number 1?
a)
1
b)
2
c)
3
d)
4
104.
Compares pairs of items and swaps them if they are in the wrong order. Each pair in the list is checked.
a)
Bubble sort
b)
Insertion sort
105.
Compares pairs of items and swaps them if they are in the wrong order. Each pair in the list is checked.
a)
Bubble sort
b)
Insertion sort
106.
The process keeps repeating until there are no swaps in a pass.
a)
Bubble sort
b)
Insertion sort
107.
Takes each item in turn and puts it in the right place using the first item in the list as a starting point.
a)
Bubble sort
b)
Insertion sort
108.

Which algorithm splits the arrays into sub-arrays of 1 element.

a)

Binary search

b)

Linear Search

c)

Merge sort

d)

Insertions sort

e)

Bubble sort

109.
Which type of sort algorithm is this?
a)
Bubble
b)
Merge
c)
Insertion
110.
Where can Linear Search be performed?
a)
On letters
b)
On numbers
c)
Both
d)
None of these
111.
On average, which searching algorithm is more efficient?
a)
Binary Search
b)
Linear Search
112.
How many linear searches will it take to find the value 7 in the list [1,4,8,7,10,28]?
a)
2
b)
3
c)
4
d)
5
113.
A Linear search algorithm requires data to be ordered.
a)
True
b)
False
114.
What is a disadvantage of the Linear search algorithm?
a)
It will only work on a sorted data set
b)
May be too slow to process large data sets
115.

How does a binary search algorithm work?​

a)

Dividing the list into halves until the item is matched with one in the list.​

b)

Starts with the first element and checks the next element consecutively until a match is found.

c)

​ None of the above​

116.
Where can Linear Search be performed?
a)
On letters
b)
On numbers
c)
Both
d)
None of these
117.
How many linear searches will it take to find the value 7 in the list [1,4,8,7,10,28]?
a)
2
b)
3
c)
4
d)
5
118.
A Linear search algorithm requires data to be ordered.
a)
True
b)
False
119.
What is an advantage of the Linear search algorithm?
a)
Performs well with small sized data sets
b)
Can be used on data sets with more than a million elements
c)
Is complicated to code
120.
What is a disadvantage of the Linear search algorithm?
a)
It will only work on a sorted data set
b)
May be too slow to process large data sets