wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Refresher

Total questions: 50

Worksheet time: 26mins

Name
Class
Date
1.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
2.
What is the position of the name "Robert" in the following list:
a)
0
b)
1
c)
2
d)
3
3.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
4.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
5.
Each item in a list has an "address" or index. The first index in a Python list is what?
a)
0
b)
1
c)
a
d)
A
6.
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
7.
What output will this code produce?
a)
['France', 'Wales', 'England']
Ireland
b)
['France', 'Ireland', 'England']
c)
['France', 'Ireland', 'Wales', 'England']
d)
['Ireland', 'Wales', 'England']
8.
In a list called "players" if you wanted to delete the item with an index of 3 which of the following examples of code would be correct?
a)
players.pop[3]
b)
players.delete(3)
c)
players.remove(3)
d)
players.pop(3)
9.
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")
10.
If you want to create an empty list called colours, which of the following pieces of code is correct?
a)
colours = [ ]
b)
colours = ( )
c)
colours = { }
d)
colors = [ ]
11.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
12.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
13.
What output will this code produce?
a)
3
b)
20
c)
25
d)
17
14.
What output will this code produce?
a)
1
b)
3
c)
2
d)
4
15.
What output will this code produce?
a)
1
b)
3
c)
i
d)
0
16.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
17.
What output will this code produce?
a)
red
b)
['blue', 'green', 'red']
c)
['red', 'green', 'blue']
d)
error
18.
What output will this code produce?
a)
['blue', 'green', 'red', 'yellow']
b)
['blue', 'red', 'yellow']
c)
['yellow', 'red', 'green']
d)
['yellow', 'red', 'blue']
19.

What output will this code produce?

a)

['blue', 'green', 'red', 'yellow']

b)

['blue', 'red', 'yellow']

c)

['yellow', 'red', 'green']

d)

['yellow', 'red', 'blue']

20.
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']
21.

Why do we learn Python?

a)

It's a really big snake

b)

It's the name of a very funny comedy show

c)

It's simple and easy to learn

d)

It's so rare that no one else knows it

22.
What will the output be from the following code?
print("Hello world!")
a)
SyntaxError
b)
Hello world!
c)
"Hello world!"
d)
print(Hello world!)
23.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
24.
print("12"*3)
What would this print?
a)
36
b)
121212
c)
24
d)
12*3
25.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
26.
What will the output be from the following code?
Print("Hello world!")
a)
NameError
b)
Hello world!
c)
"Hello world"
d)
Print(Hello world!)
27.
What will the output be from the following code?
print("Hello" + "world" + "today")
a)
Helloworldtoday
b)
Hello world today
c)
"Hello" "world" "today"
d)
SyntaxError
28.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
29.
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!
30.
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
31.
What will the output be from the following code?
print(9/3)
a)
3
b)
3.0
c)
9/3
d)
SyntaxError
32.
Which function takes a users input
a)
print()
b)
int()
c)
input()
d)
def
33.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
34.
Which is the most appropriate data type for: "13th December"
a)
Float
b)
Boolean
c)
Integer
d)
String
35.
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
36.
A location in memory used to store data that can be changed.
a)
Constant
b)
Value
c)
Variable
d)
Iteration
37.
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
38.

In a stack, if a user tries to remove an element from empty stack it is called _________

a)

Underflow

b)

Empty collection

c)

Overflow

d)

Garbage Collection

39.

Process of inserting an element in stack is called ____________

a)

Create

b)

Push

c)

Evaluation

d)

Pop

40.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced.

Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).

The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

a)

1

b)

2

c)

3

d)

4 or more

41.

User perform following operations on stack of size 5 then -

push(1);

pop();

push(2);

push(3);

pop();

push(2);

pop();

pop();

push(4);

pop();

pop();

push(5);

a)

Overflow Occurs

b)

Stack Operations will be performed Smoothly

c)

Underflow Occurs

d)

None of these

42.

What is the value of the postfix expression 6 3 2 4 + – *

a)

1

b)

40

c)

74

d)

-18

43.

The following postfix expression with single digit operands is evaluated using a stack:

8 2 3 ^ / 2 3 * + 5 1 * -

a)

6,1

b)

5,7

c)

3,2

d)

1,5

44.

To evaluate an expression without any embedded function calls:

a)

One stack is enough

b)

Two stacks are needed

c)

As many stacks as the height of the expression tree are needed

d)

A Turing machine is needed in the general case

45.

What will be the postfix form of the above expression -

(A+B)∗(C∗D-E)∗F/G

a)

None of these

b)

A B + C D ∗ E − F G ∗ / ∗

c)

A B + C D E ∗ − F G / ∗ ∗

d)

A B + C D ∗ E − F G / ∗ ∗

46.

Which one of the following is an application of Stack Data Structure?

a)

Managing function calls

b)

The stock span problem

c)

Arithmetic expression evaluation

d)

All of the above

47.

List of data in which element can be inserted and removed at the same end is called as __________.

a)

array

b)

stack

c)

linked list

d)

queue

48.
Which of the following is the best definition of a VARIABLE?
a)
A variable is container of data
b)
A variable is piece of data
c)
A variable is a number
d)
A variable is a piece of text
49.
Amy creates a program which includes the variable shown here.
What would be the best way of describing "lives"?
a)
"lives" is string
b)
"lives" is an identifier
c)
"lives" could be used in a game
d)
"lives" is a float
50.
Matt wants to create a program to keep a record of temperatures. 
Which DATA TYPE would be most suitable for a variable called "temperature"?
a)
A string
b)
A boolean
c)
An integer 
d)
A float