NEW
Font size
S
M
L
XL
WorksheetsSST Yr8 - NCCE - Programming
Total questions: 20
Worksheet time: 10mins
Name
Class
Date
1.
Question 1:
The process of finding errors in your code and removing or solving them is called?
a)
A – Filtering
b)
B – Probing
c)
C – Debugging
d)
D – Refining
2.
Question 2:
Manisha has written the following code and when she runs it, she receives an error.
name=input(“Please enter your name: “)
print(“Welcome “ name “… loading main menu”)
What does Manisha need to do for the code to run as expected?
a)
A: Include concatenation in the print statement
b)
B: The user input needs to be cast to the correct datatype
c)
C: Remove the brackets in the print statement
d)
D: Replace the speech marks with single quotations
3.
Question 3:
What term do we give to code that contains actions that must be executed one after the other without skipping any.
a)
A: Iteration
b)
B: Sequence
c)
C: Selection
d)
D: Decomposition
4.
Question 4:
The following code is an example of which programming construct?
if choice == 1:
print(“Welcome to the user account area”)
elif choice == 2:
print(“Welcome to the quiz area”)
else:
print(“You are now being logged off”)
a)
A: Sequence
b)
B: Iteration
c)
C: Decomposition
d)
D: Selection
5.
Question 5:
The following code is an example of which programming construct?
for i = 1 to 10
print(i)
next i
print(“Coming, ready or not”)
a)
A: Repetition
b)
B: Sequence
c)
C: Decomposition
d)
D: Selection
6.
Question 6:
Which of the following code makes use of a function?
a)
A: Total = Price * Quantity
b)
B: Name = “Minahil”
c)
C: While Grade != 5
d)
D: Name = input(“Enter your name”)
7.
Question 7:
What arithmetic operator should replace the ‘+’ to give the output the total made from ticket sales?
Cost = input(“Enter cost per ticket”)
Quantity = input(“Enter the number of tickets sold”)
total = Cost + Quantity
a)
A: DIV
b)
B: /
c)
C: MOD
d)
D: *
8.
Question 8:
Akhil has written a program to validate the height of a child wishing to ride a roller coaster: He runs the program and enters the height as being 1.5.
What does the program output?
if height <= 1.5
print (“You are not tall enough to ride the roller
coaster”)
elif height >= 2.0
print (“You are too tall to ride the roller coaster”)
else
print (“You can ride the roller coaster”)
a)
A: You are too tall to ride the roller coaster
b)
B: Nothing
c)
C: You are not tall enough to ride the roller coaster
d)
D: You can ride the roller coaster
9.
Question 9:
Which of the following relational operators would be needed to check if a variable holds a value greater or equal to 100:
a)
A: <
b)
B: >
c)
C: <=
d)
D: >=
10.
Question 10:
Grace has written the following program to validate some user input in response to a question:
She has used a Boolean operator AND in her code. What Boolean operator should she have used?
if answer == “yes” AND answer == “YES”
print (“That’s correct, well done”)
else
print (“Sorry that is not the correct answer, please try again”)
a)
A: EQUALTO
b)
B: XOR
c)
C: NOT
d)
D: OR
11.
Question 11:
Siqi has designed an algorithm which includes the following code:
destination = "Paris"
length = destination.length
What programming technique has Siqi used?
a)
A: String manipulation
b)
B: Selection
c)
C: Iteration
d)
D: Repetition
12.
Question 12:
What would be the output generated from the following code?
subject = “Computer Science”
print(subject.substring(3,5))
a)
A: nce
b)
B: puter
c)
C: ience
d)
D: ute
13.
Question 13:
Alex has written the following code:
fname = input(“Enter your first name”)
lname = input(“Enter your last name”)
print(“Your username is “ + fname +
lname.substring(0,1))
He is testing the code and has entered the values Laurel and Etherington.
What output should he expect?
a)
A: LaurelE
b)
B: LEtherington
c)
C: LaurelEtherington
d)
D: LE
14.
Question 14:
Sid has written the following code to store items that have been added to a bag in a computer game:
array bag[“Magic cucumber”, “Invisibility cloak”, “Jet boots”, “Fortune jelly”]
He wishes to replace Jet boots with Super Hammer in the array. Which code should he include in his program?
a)
A: bag[3] = Super Hammer
b)
B: bag[4] = “Super Hammer”
c)
C: bag[2] = “Super Hammer”
d)
D: bag[1] = Super Hammer
15.
Question 15:
Which of the following is NOT true about arrays?
a)
A: An array can store a collection of data items
b)
B: An array has an index
c)
C: An array is a static data structure
d)
D: An array can store data of different data types
16.
Question 16:
Which of the following is NOT a reason for using functions when programming?
a)
A: To make code more readable
b)
B: To reduce repetition of code
c)
C: To make code easier to debug
d)
D: To reduce the amount of memory needed for the program to run
17.
Question 17:
What would the following program output?
A = True
B = False
C = NOT A AND B
print(C)
a)
A: True
b)
B: False
c)
C: NOT C
d)
D: C
18.
Question 18:
colour = input(“Enter your favourite colour”)
What is ‘colour’ an example of?
a)
A: Relational operator
b)
B: Boolean operator
c)
C: Variable
d)
D: Constant
19.
Question 19:
Which of the following statements could be used as a selection construct?
a)
A: while x < y
b)
B: if x == y
c)
C: print(“Hello”)
d)
D: for i=0 to 9
20.
Question 20:
Freya has written the following program. What would the program output if it were run?
x = 3
while x > 1
print (“tick”)
x = x-1
print (“tock”)
a)
A: tick, tock, tick, tock
b)
D: tick, tick, tick
c)
C: tick, tick, tick, tock
d)
D: tick, tick, tock
Reset
