wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
2.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
3.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
4.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
5.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
6.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
7.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
8.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
9.
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
10.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
11.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
12.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
13.

What are the names of the two types of mode that are used in Python? Select two.

a)

Interactive mode

b)

Scratch mode

c)

Imperial mode

d)

Script mode

14.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
15.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
16.
What does the APPEND procedure do in the following code:
a)
Adds Liverpool to the beginning of the list
b)
Replaces Bristol with Liverpool
c)
Replaces Manchester with Liverpool
d)
Adds Liverpool to the end of the list
17.
What output will this code produce?
a)
['France', 'Wales', 'England']
France
b)
['France', 'Wales', 'England']
Wales
c)
France, Wales, England
Wales
d)
France  Wales  England
France
18.
What output will this code produce?
a)
['France', 'Wales', 'England']
Ireland
b)
['France', 'Ireland', 'England']
c)
['France', 'Ireland', 'Wales', 'England']
d)
['Ireland', 'Wales', 'England']
19.
In a list called "players", if you wanted to add a player called "Bob" to the list, which of the following examples of code would be correct?
a)
players.add("Bob")
b)
player.append("Bob")
c)
players.append("Bob")
d)
players.addend("Bob")
20.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
21.
What output will this code produce?
a)
3
b)
20
c)
25
d)
17
22.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
23.
What output will this code produce?
a)
['Bristol', 'Exeter', 'London', 'Manchester']
b)
['Manchester', 
'London',  'Exeter', 'Bristol']
c)
['Manchester', 
'Bristol', 'Exeter', 'London',  ]
d)
['London',  'Exeter', 'Bristol', 'Manchester']
24.

To insert an the string "strawberries" in the first position of a list we use

a)

fruit.append("strawberries, 1")

b)

fruit.insert("strawberries",0)

c)

fruit.insert(1, "strawberries")

d)

fruit.insert(0, "strawberries")

25.
What will the output be from the following code?
print(9/3*2+4-5)
a)
19
b)
5.0
c)
0.5
d)
5
26.

What is a Count-Controlled loop?

a)

for loop

b)

while loop

27.

Which of these is NOT a loop in python?

a)

for loop

b)

while loop

c)

nested loop

d)

if loop

28.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

29.

What will be the output of this code?

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,2,4,6,8,10

c)

2,4,6,8,10,12

d)

2,4,6,8,10

30.

If i want to continuously check for a correct answer, what loop would i use?

a)

for loop

b)

while loop

31.

Which of the following is invalid?

a)

_a = 1

b)

__a = 1

c)

__str__ = 1

d)

none of the mentioned

32.

Which of the following is an invalid statement?

a)

abc = 1,000,000

b)

a b c = 1000 2000 3000

c)

a,b,c = 1000, 2000, 3000

d)

a_b_c = 1,000,000

33.

What is the output of this expression, 3*1**3?

a)

27

b)

9

c)

3

d)

1

34.

We can insert the new item into tuple

a)

True

b)

False

35.

You are in the car with traffic jammed at a junction. To cross that junction according to the traffic rules, which one is NOT applicable

a)

While loop

b)

Conditional Statement

c)

For loop