Font size
WorksheetsYear 8 CS Quiz
Total questions: 120
Worksheet time: 1hrs 18mins
1)Which of the following characters is used to give single-line comments in Python?
a)//
b) #
c) !
d) /*
2)What data type will be displayed from the code { print(type(10))?
a) Float
b) string
c) int
d) boolean
3)A_____ in python that is used to define numbers.
a) Integer
b) Boolean
c) Float
d) String
4)A _____ in Python is used to define numbers with decimals.
a)Boolean
b)Float
c)String
d)Integer
5)What programming language uses the following logo?
a) HTML
b)Python
c)Java
d)CSS
6)Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
7)What data type is the object below?
L = [1, 23, 'hello', 1]
a) list
b) dictionary
c) array
d) tuple
8)An algorithm can be defined as . . .
a) deciding which statement is true
b)repeating the same code several times
c)a set of steps to complete a task
d)representing data as zeros and ones (0 & 1)
9)A method of focusing on what is important first . . .
a)Pattern recognition
b)Decomposition
c)Algorithm
d)Abstraction
10)The IPO model explains how the computer works. It stands for Input, Processing and ___________
a)Outburst
b)Output
c)Outback
d)Outside
12)Complete the following coding segment:
name = "Hamed"
_______("Welcome ", name)
a) Print
b) Input
c) Type
d) Def
13)Which of the following statements assigns the value 25 to the variable x in Python?
a)x ← 25
b)x = 25
c)x := 25
d)int x = 25
14)How can we get 6 from the given list?
list=[9,5,6,3]
a)list[2]
b)list[3]
c)list[0]
d)list[-3]
15)What will the result be of the following Python code:
teams=["Brazil", "France", "England", "Argentina"]
teams.sort()
print(teams)
a)["Argentina", "Brazil", "England", "France"]
b)["Brazil", "France", "England", Argentina"]
c)["Brazil", "France", "England"]
d)["England", "France", "Argentina", "Brazil"]
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)Hello Pythonista
b)You should try a little Python too Hello Pythonista
c)Hello Pythonista You should try a little Python too
d)You should try a little Python too
a = 13
b = a + 1
a = 42
print(b)
17) When this program is run, what will be displayed on the screen?
a)14
b)43
c)There is an error in the program because variable b cannot hold two values at the same time
d)14 43
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)13 26
b)Line 3 will not be executed
c)13
d)26
19)What does this diagram represent?
a) graph
b) flowchart
c) organization structure
d) flow
Convert the following binary value into denary
0 0 0 1 1 0 1 1
(a)
Convert the following binary value into denary
1 1 1 0 0 1 1 0
(a)
Convert denary 87 to binary
(a)
Denary 37 to Hex
(a)
Denary 59 to Hex
(a)
Hex 2F to Denary
(a)
Hex 1A to Binary
(a)
Hex 16 to Binary
(a)
Binary 0011 0111 to Hex
(a)
Binary 1101 1111 to Hex
(a)
The binary number 1110 0100 is an even number.
Explain why this is the case with reference to the rightmost bit.
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.
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.
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.
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)
Which is the best answer to explain why computers use binary.
Computers use circuits and logic gates. 1 or 0 represents on and off, which is true or false.
Computers understand binary easier than human language so it can compile code faster.
Computers have 8 states which are the bit values of binary to work out numbers.
Computers use true or false statements and that is what 1 and 0 is.
How many bits are there in a Nibble? (Just give the number)
(a)
How many bits are there in a byte? (Just give the number)
(a)
How many bytes are there in a kibibyte? (Just give the number)
(a)
Which of these lists show the correct order for data storage capacities?
bit
nibble
byte
kibibyte
mebibyte
gibibyte
bit
nibble
mebibyte
byte
kibibyte
gibibyte
byte
kibibyte
gibibyte
bit
nibble
mebibyte
kibibyte
mebibyte
gibibyte
bit
nibble
byte
Which logic gate is this?
AND
OR
XOR
NOT
A truth table lists every possible combination of input and the resulting output
True
False
word = "amazing"
For the given string if we run word[2:5] , what would the result be?
mazi
mazin
azi
azin
Which of the following is not a valid string function?
isalphanumeric
isspace
islower
isalnum
string="HELlo"
What will be the result of string.isupper()?
(a)
What is printed by the following statement?
print("P" not in "APCSP")
True
False
Error
What is printed by the following statement?
print("A" in "APCSP")
True
False
Error
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
data = "No Way!" The expression len(data) evaluates to:
7
9
8
6
Which operator returns True if target string is somewhere in the search string; otherwise it returns False.
==
!=
in
is
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\l
/
\\n
\n
Which is the most appropriate data type for: "13th December"
Float
Boolean
Integer
String
What will the output be from the following code?
print("Hello world!" * 2)
TypeError
Hello world world!
Hello world!Hello world!
Hello world! * 2
What will the output be from the following code?
print("Hello world!\nHello world!")
Hello world! Hello world!
Hello world!
Hello world!
SyntaxError
Hello world!
What will the output be from the following code?
print("3+4")
7
34
3+4
SyntaxError
print("12"*3)
What would this print?
121212
36
24
12*3
A variable is a named value that can be changed in the program.
False
True
What is a String?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
Which value is a String?
64
"cat"
True
0.5
What is an Integer?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
Which value is an Integer?
64
"cat"
True
0.5
What is a Float?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
Which value is a Float?
64
"cat"
True
0.5
What is a Boolean?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
Which value is a Boolean?
64
"cat"
True
0.5
Which writes a message for the user?
input()
myVar="Hi"
print("Hello!")
max=100
Which of the following is NOT a basic file handling operation?
Read
Write
Open
Execute
What is the purpose of the 'Close' operation in file handling?
To delete the file from the directory
To save changes to the file
To end the file handling session
To copy the file to another location
What is the primary function of a file handler in computer programming?
To display data on the screen
To store the external file in RAM so that the running program can work on it
To manage user inputs
To point to a file with a variable so the program can access it.
What role does a cursor play in file handling?
It encrypts the data being written to a file
It manages the security of a file
It keeps track of the current location within the file when reading or writing
It compresses the file data for storage efficiency
What is the purpose of the 'open()' function in programming?
To close a file
To delete a file
To read from or write to a file
To rename a file
What must be provided to the 'open()' function to successfully open a file?
The file's size
The file's creation date
The file's name including its file extension
The file's read/write speed
What does the 'file handle' refer to in the context of opening a file?
A tool to physically handle the file
A special variable that stores the file's data
A special variable that refers to the opened file
The user interface for managing files
What is the purpose of using '\n' in the write statement when writing to a file in Python?
To indicate the end of the program
To add a new line character
To delete the previous line
To make the text bold
Which method is used to write text to a file in Python?
file.append()
file.read()
file.write()
file.save()
What does the 'readline()' function do when reading a file in Python?
It reads the entire file at once.
It reads the next character in the file.
It reads the current line from the file and then moves the cursor to the next line.
It reads the next line from the file.
12 6 8 1 3
How many comparisons would it take to find number 1?
Which algorithm splits the arrays into sub-arrays of 1 element.
Binary search
Linear Search
Merge sort
Insertions sort
Bubble sort
How does a binary search algorithm work?
Dividing the list into halves until the item is matched with one in the list.
Starts with the first element and checks the next element consecutively until a match is found.
None of the above
