Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Computers December 13

Total questions: 25

Worksheet time: 38mins

Name
Class
Date
1.

What is a list in python?

a)

A collection of variables

b)

A collection of items assigned to a single variable

c)

A statement that cant be changed

d)

A Christmas list

2.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
3.
What will the output be from the following code?
print(9/3)
a)
3
b)
3.0
c)
9/3
d)
SyntaxError
4.
What will the output be from the following code?
print("Hello" + "world!")
a)
Hello world!
b)
Helloworld!
c)
SyntaxError
d)
"Hello" "world!"
5.
What will the output be from the following code?
print("Hello" + 2 + "world")
a)
Hello 2 world
b)
Hello2world
c)
TypeError
d)
HelloHelloworld
6.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
7.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
8.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
9.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
10.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
11.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

12.

List items have an index number. In the following list, which item has the index number of 3?

["Barry", "Harry", "Jesse", "John", "Peter", "Harry"]

a)

"Barry"

b)

"Harry"

c)

"Jesse"

d)

"John"

13.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
14.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
15.
What is printed when this program is run:
days = 5 
if days > 6:  
   print(“Month”)

else:  
   print(“Week”)
a)
Month
b)
Week
c)
Day
d)
4
16.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
17.
What will the following lines of code print?
a)
A
b)
B
C
c)
A
C
d)
Nothing, it will return an error.
18.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

19.

The list needs one more name added to the end - "Felipe". Which piece of code below would do this?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

20.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
21.

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

a)

Yes

b)

No

22.

Consider this list, what will be the highest index the list can have:

li=[1,2,3,4,5]

a)

2

b)

3

c)

4

d)

5

23.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3

24.

mylist = ["a","b"]

mylist[1] = "c"'

print(mylist)

a)

["a","c"]

b)

["a","b"]

c)

["a","b","c"]

d)

mylist

25.

What would the output of the program be?

thisList = ["square", "circle", "triangle", "octagon"]

if "triangle" in thisList:

print("Yes, 'triangle' is in the list")

else:

print("No triangle here!")

a)

Yes, 'triangle' is in the list

b)

"No triangle here!"