wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python revision

Total questions: 79

Worksheet time: 1hrs 3mins

Name
Class
Date
1.

When you open the Python interface you first see the​ (a)  

There are 3 arrows that are a prompt for you to enter​ (b)  

The command you type in is performed when you​ (c)  

Choose from the below words
interactive shell
a single command
multiple commands
press enter
click on Run
interactional screen
2.

In Python, the command to make text appear on the screen is...

a)

print

b)

PRINT

c)

output

d)

display

3.

When you finish typing the word print into the shell, the word changes colour - what colour does it become?

a)

blue

b)

red

c)

green

d)

purple

4.

Which of these commands would produce an error message?

a)

print("Hello")

b)

print('Hello')

c)

print(Hello)

5.

Which of these commands would produce an error message?

a)

print("Hello")

b)

print('Hello')

c)

print"Hello"

6.

What would be the result of entering the command below?

PRINT("Hello")

a)

Error message

b)

Hello is printed

c)

Nothing, it will wait for more commands

7.

What would be the result of entering the command below?

print("That's right!")

a)

Error message

b)

That's right! is printed

c)

Nothing, it will wait for more commands

8.

What would be the result of entering the command below?

print('That's right!')

a)

Error message

b)

That's right! is printed

c)

Nothing, it will wait for more commands

9.

What would be the result of entering the command below?

print(2*"Hello")

a)

Error message

b)

Hello

Hello

c)

HelloHello

10.

What command would produce the output shown below?

Hello

Hello

a)

print(2*"Hello\n")

b)

print(2*"Hello"\n)

c)

print("Hello\n")*2

d)

print(2*"Hello/n")

11.

A variable is a​ (a)   that​ (b)   .

The value of the variable​ (c)   as the program runs.

Choose from the below words
named piece of memory
holds a value
can change
cannot change
12.

The command below​ (a)   the value ​ (b)   to the ​ (c)   ​ (d)   .

x = 4

Choose from the below words
assigns
4
x
imports
variable
constant
13.

The command below​ (a)   the value ​ (b)   to the ​ (c)   ​ (d)   .

name = "Elizabeth"

Choose from the below words
assigns
"Elizabeth"
name
gives
variable
text
14.

What would be the output on the screen when the program below is run?

a = 7

print(a)

a)

7

b)

a

c)

error message

15.

What would be the output on the screen when the program below is run?

a = 7

print("a")

a)

7

b)

a

c)

error message

16.

What would be the output on the screen when the program below is run?

a = 7

print(A)

a)

7

b)

a

c)

error message

17.

The program below produces an error message:

Name = Emma

print(Name)

What is the reason for the error message?

a)

The 1st line should be Name = "Emma"

b)

The variable Name should be name

c)

The word Name cannot be used as a variable

d)

The 2nd line should be print("Name")

18.

What would be the output on the screen when the program below is run?

Name = "Judy"

Name = "Mike"

print(Name)

a)

Mike

b)

Name

c)

error message

d)

Judy

19.

What would be the output on the screen when the program below is run?

Name = "Barry"

print("User's name is" + Name)

a)

User's name isBarry

b)

User's name is Barry

c)

error message

d)

User's name is Name

20.

What would be the output on the screen when the program below is run?

Name = "Barry"

print("User's name is",Name)

a)

User's name isBarry

b)

User's name is Barry

c)

error message

d)

User's name is Name

21.

What is the result of the following command in Python?

15 / 5

(a)  

22.

What is the result of the following command in Python?

7 + 4

(a)  

23.

What is the result of the following command in Python?

6 * 3

(a)  

24.

What is the result of the following command in Python?

17 - 9

(a)  

25.

What is the result of the following command in Python?

3 ** 2

(a)  

26.

What is the result of the following command in Python?

2 ** 5

(a)  

27.

What is the result of the following command in Python?

2 ** 5

(a)  

28.

What is the result of the following command in Python?

13 // 4

(a)  

29.

What is the result of the following command in Python?

13 % 4

(a)  

30.

What is the result of the following command in Python?

39 // 8

(a)  

31.

What is the result of the following command in Python?

39 % 8

(a)  

32.

Match up each command with its correct result

a)

2 ** 3

1.

8

b)

3 ** 2

2.

9

c)

3 * 2

3.

6

d)

23 // 5

4.

4

e)

23 % 9

5.

5

33.

What is the result of the Python command below?

6 != 5

a)
True
b)
False
34.

What is the result of the Python command below?

10 != 10

a)
True
b)
False
35.

What is the result of the Python command below?

4.3 != 4

a)
True
b)
False
36.

What is the result of the Python command below?

7 > 6

a)
True
b)
False
37.

What is the result of the Python command below?

3 < 2

a)
True
b)
False
38.

What is the result of the Python command below?

4.3 > 4

a)
True
b)
False
39.

What is the result of the Python command below?

3 > 3

a)
True
b)
False
40.

What is the result of the Python command below?

5 <= 5.7

a)
True
b)
False
41.

What is the result of the Python command below?

3 >= 3

a)
True
b)
False
42.

Decide whether each statement is True or False

Categorize the following

6 == 6

4 < 7

8 > 5

7 >= 7

5 <= 5

3.7 < 4

6.1 > 6

3.5 != 3

5 == 6

8 < 5

7 > 8

4 >= 5

3.5 > 4

6.1 < 6

3.5 == 3.5

2 != 2

True
False
43.
_______ is how we write code
a)
Syntax
b)
Loops
c)
Variables
d)
Functions
44.

What is the purpose of a conditional statement?

a)

It allows different routes through a program, dependent on meeting certain criteria

b)

It allows a section of code to be repeated

c)

It is a subroutine that returns a value

d)

It sets the initial value of a variable

45.

What is the name of a subroutine that always returns a value?

a)

Function

b)

Procedure

c)

Loop

d)

Library routine

46.

What is the name of a subroutine that does not return a value?

a)

Function

b)

Procedure

c)

Loop

d)

Library routine

47.

Is the following subroutine a procedure or a function?

def chooseOption

print("Enter 1, 2 or 3)

choice = input()

return(choice)

a)

Procedure

b)

Function

48.

Which of the following is a description of a variable?

a)

A collection of related data

b)

A value that does not change during a program

c)

A value that may change during a program

d)

A list of elements of the same data type

49.

Which of the following is a description of a constant?

a)

A collection of related data

b)

A value that does not change during a program

c)

A value that may change during a program

d)

A list of elements of the same data type

50.

Which of the following is a description of an array?

a)

A collection of related data

b)

A value that does not change during a program

c)

A value that may change during a program

d)

A list of elements of the same data type

51.

A programmer creates a game and wants to store the highest score achieved by its players.

 

Choose the data structure that would be most suitable to use.

a)

Table

b)

Array

c)

Constant

d)

Variable

52.

A programmer writes a program to store the temperature of a room each hour during the day.

 

Choose the data structure that would be most suitable to use.

a)

Table

b)

Array

c)

Constant

d)

Variable

53.

A program is to be written to store information about all the pupils in a school.

It needs to store the names and ages of the pupils.

 

Which of the following is NOT an advantage of using arrays in this example?

a)

it will be simpler to store the information in arrays (rather than lots of variables)

b)

An index can be used to access all the information about a particular pupil

c)

It will be easier to sort the pupils by name or age

d)

The program will not need to contain any loops

54.

23

The above is an example of what data type?

a)

Integer

b)

Real

c)

Char

d)

String

e)

Boolean

55.

"Hello"

The above is an example of what data type?

a)

Integer

b)

Real

c)

Char

d)

String

e)

Boolean

56.

False

The above is an example of what data type?

a)

Integer

b)

Real

c)

Char

d)

String

e)

Boolean

57.

3.14

The above is an example of what data type?

a)

Integer

b)

Real

c)

Char

d)

String

e)

Boolean

58.

'A'

The above is an example of what data type?

a)

Integer

b)

Real

c)

Char

d)

String

e)

Boolean

59.

Names = ['Ann', 'Chloe', 'Dave', 'Eve', 'Helen', 'Jim']

What is the result of Names[1] ?

a)

'Ann'

b)

'Chloe'

c)

'Dave'

d)

'Eve'

60.

Ages = [13, 17, 15, 8, 16, 12]

What is the result of Ages.index(15)

a)

0

b)

1

c)

2

d)

3

61.

How many rows are there in the Results array?

a)

2

b)

3

c)

4

d)

5

62.

How many columns are there in the Results array?

a)

2

b)

3

c)

4

d)

5

63.

What is the output of Results [0] ?

a)

[53, 78, 66, 49, 92]

b)

[43, 61, 50, 44, 75]

c)

[61, 32, 51, 78, 45]

d)

53

64.

What is the output of Results [0] [1] ?

(a)  

65.

What is the output of Results [1] [0] ?

(a)  

66.

What is the output of Results [2] [3] ?

(a)  

67.

What is the output of len(Results) ?

(a)  

68.

What is the output of Results.index([61, 32, 51, 78, 45]) ?

a)

0

b)

1

c)

2

d)

Error message

69.

What is the output of Results.index(32) ?

a)

1

b)

[2] [1]

c)

2 , 1

d)

Error message

70.

What is the output of Results[2].index(32) ?

a)

1

b)

[2] [1]

c)

2

d)

Error message

71.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

How many rows are in the array?

(a)  

72.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

How many columns are in the array?

(a)  

73.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores [2] ?

a)

9

b)

[2, 4, 3]

c)

[0, 3, 1]

d)

Error message

74.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores [2] [1] ?

a)

2

b)

0

c)

3

d)

1

75.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores [3] [1] ?

a)

3

b)

Error message

c)

12

d)

8

76.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores [4] [0] ?

a)

6

b)

Error message

c)

0

d)

8

77.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores.index( [2, 4, 3] ) ?

a)

1

b)

Error message

c)

0

d)

2

78.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores.index(12) ?

a)

1

b)

Error message

c)

3, 1

d)

[3] [1]

79.

Here is a 2D array:

Scores = [ [6, 4, 9], [2, 4, 3] , [0, 3, 1] , [8, 12, 9] ]

What is the result of Scores[3].index(12) ?

a)

1

b)

Error message

c)

3 , 1

d)

[3] [1]