wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Revision

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

Python uses parenthesis to block off code

a)

True

b)

False

2.

Python uses indentation to block code into chunks

a)

True

b)

False

3.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

4.

What result will display in the shell if 15 and 20 is entered by the user?

a)

"num1 + num2"

b)

1520

c)

35

5.

Which one will display when this code is run?

a)
b)
c)
d)
6.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
7.
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
8.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
9.

What will be the output of the following code:

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

10.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
11.
What Python command lets the user enter an answer to a question?
a)
answer()
b)
open()
c)
print()
d)
input()
12.

Which statement correctly assigns the string "Tanner" to the variable name?

a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
13.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
14.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
15.

Code for Hello, World!

a)

print Hello, World!

b)

print("Hello, World!)

c)

print("Hello, World!")

16.

Code to display the following text:

Five is greater than two!

a)

if 5 > 2:

print("Five is greater than two!")

b)

if 5 = 2:

print("Five is greater than two!")

c)

if 5 > 2: Print("Five is greater than two!")

17.

Code which will give the following output:

257

Hello, World!

a)

x = 257

y = "Hello, World!"


print(y)

print(x)

b)

x = 257

y = "Hello, World!"


print(x)

print(y)

c)

x = 257

y = Hello, World!


print x

print y

18.

Insert the missing part of the code below to output

_________________( "My name is ")

a)

Print

b)

PRINT

c)

print

19.

Comments in Python are written with the special character:

a)

brackets

b)

hashtag

c)

coma

20.

Code to display the following:

b is greater than a

a)

a = 33

b = 200


if b > a:

print("b is greater than a")

b)

a = 33

b = 200


if b < a:

print("b is greater than a")

c)

a = 330

b = 200


if b > a:

print("b is greater than a")

21.

The output of the program is:

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

22.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
23.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

24.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
25.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
26.
What output will this code produce?
a)
3
b)
20
c)
25
d)
17
27.
What output will this code produce?
a)
1
b)
3
c)
2
d)
4
28.

What will the output be from the following code?

print(3+4)

a)

3+4

b)

7

c)

SyntaxError

d)

print(3+4)

29.
print("12"*3)
What would this print?
a)
36
b)
121212
c)
24
d)
12*3
30.

What will the output be from the following Python code?

print(9/3)

a)

3

b)

3.0

c)

9/3

d)

SyntaxError

31.

What will the output be from the following Python code?

print(Hello world!)

a)

Hello world!

b)

SyntaxError

c)

Hello world

d)

print(Hello world!)

32.
A location in memory used to store data that can be changed.
a)
Constant
b)
Value
c)
Variable
d)
Iteration
33.

What is the Python built-in function to converts a number to a string?

a)

str()

b)

int()

c)

parseInt()

d)

convert

34.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
35.

Which of these is correct Python conditional statement?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":