Font size
WorksheetsPython revision
Total questions: 79
Worksheet time: 1hrs 3mins
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)
In Python, the command to make text appear on the screen is...
output
display
When you finish typing the word print into the shell, the word changes colour - what colour does it become?
blue
red
green
purple
Which of these commands would produce an error message?
print("Hello")
print('Hello')
print(Hello)
Which of these commands would produce an error message?
print("Hello")
print('Hello')
print"Hello"
What would be the result of entering the command below?
PRINT("Hello")
Error message
Hello is printed
Nothing, it will wait for more commands
What would be the result of entering the command below?
print("That's right!")
Error message
That's right! is printed
Nothing, it will wait for more commands
What would be the result of entering the command below?
print('That's right!')
Error message
That's right! is printed
Nothing, it will wait for more commands
What would be the result of entering the command below?
print(2*"Hello")
Error message
Hello
Hello
HelloHello
What command would produce the output shown below?
Hello
Hello
print(2*"Hello\n")
print(2*"Hello"\n)
print("Hello\n")*2
print(2*"Hello/n")
A variable is a (a) that (b) .
The value of the variable (c) as the program runs.
The command below (a) the value (b) to the (c) (d) .
x = 4
The command below (a) the value (b) to the (c) (d) .
name = "Elizabeth"
What would be the output on the screen when the program below is run?
a = 7
print(a)
7
a
error message
What would be the output on the screen when the program below is run?
a = 7
print("a")
7
a
error message
What would be the output on the screen when the program below is run?
a = 7
print(A)
7
a
error message
The program below produces an error message:
Name = Emma
print(Name)
What is the reason for the error message?
The 1st line should be Name = "Emma"
The variable Name should be name
The word Name cannot be used as a variable
The 2nd line should be print("Name")
What would be the output on the screen when the program below is run?
Name = "Judy"
Name = "Mike"
print(Name)
Mike
Name
error message
Judy
What would be the output on the screen when the program below is run?
Name = "Barry"
print("User's name is" + Name)
User's name isBarry
User's name is Barry
error message
User's name is Name
What would be the output on the screen when the program below is run?
Name = "Barry"
print("User's name is",Name)
User's name isBarry
User's name is Barry
error message
User's name is Name
What is the result of the following command in Python?
15 / 5
(a)
What is the result of the following command in Python?
7 + 4
(a)
What is the result of the following command in Python?
6 * 3
(a)
What is the result of the following command in Python?
17 - 9
(a)
What is the result of the following command in Python?
3 ** 2
(a)
What is the result of the following command in Python?
2 ** 5
(a)
What is the result of the following command in Python?
2 ** 5
(a)
What is the result of the following command in Python?
13 // 4
(a)
What is the result of the following command in Python?
13 % 4
(a)
What is the result of the following command in Python?
39 // 8
(a)
What is the result of the following command in Python?
39 % 8
(a)
Match up each command with its correct result
2 ** 3
8
3 ** 2
9
3 * 2
6
23 // 5
4
23 % 9
5
What is the result of the Python command below?
6 != 5
What is the result of the Python command below?
10 != 10
What is the result of the Python command below?
4.3 != 4
What is the result of the Python command below?
7 > 6
What is the result of the Python command below?
3 < 2
What is the result of the Python command below?
4.3 > 4
What is the result of the Python command below?
3 > 3
What is the result of the Python command below?
5 <= 5.7
What is the result of the Python command below?
3 >= 3
Decide whether each statement is True or False
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
What is the purpose of a conditional statement?
It allows different routes through a program, dependent on meeting certain criteria
It allows a section of code to be repeated
It is a subroutine that returns a value
It sets the initial value of a variable
What is the name of a subroutine that always returns a value?
Function
Procedure
Loop
Library routine
What is the name of a subroutine that does not return a value?
Function
Procedure
Loop
Library routine
Is the following subroutine a procedure or a function?
def chooseOption
print("Enter 1, 2 or 3)
choice = input()
return(choice)
Procedure
Function
Which of the following is a description of a variable?
A collection of related data
A value that does not change during a program
A value that may change during a program
A list of elements of the same data type
Which of the following is a description of a constant?
A collection of related data
A value that does not change during a program
A value that may change during a program
A list of elements of the same data type
Which of the following is a description of an array?
A collection of related data
A value that does not change during a program
A value that may change during a program
A list of elements of the same data type
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.
Table
Array
Constant
Variable
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.
Table
Array
Constant
Variable
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?
it will be simpler to store the information in arrays (rather than lots of variables)
An index can be used to access all the information about a particular pupil
It will be easier to sort the pupils by name or age
The program will not need to contain any loops
23
The above is an example of what data type?
Integer
Real
Char
String
Boolean
"Hello"
The above is an example of what data type?
Integer
Real
Char
String
Boolean
False
The above is an example of what data type?
Integer
Real
Char
String
Boolean
3.14
The above is an example of what data type?
Integer
Real
Char
String
Boolean
'A'
The above is an example of what data type?
Integer
Real
Char
String
Boolean
Names = ['Ann', 'Chloe', 'Dave', 'Eve', 'Helen', 'Jim']
What is the result of Names[1] ?
'Ann'
'Chloe'
'Dave'
'Eve'
Ages = [13, 17, 15, 8, 16, 12]
What is the result of Ages.index(15)
0
1
2
3
How many rows are there in the Results array?
2
3
4
5
How many columns are there in the Results array?
2
3
4
5
What is the output of Results [0] ?
[53, 78, 66, 49, 92]
[43, 61, 50, 44, 75]
[61, 32, 51, 78, 45]
53
What is the output of Results [0] [1] ?
(a)
What is the output of Results [1] [0] ?
(a)
What is the output of Results [2] [3] ?
(a)
What is the output of len(Results) ?
(a)
What is the output of Results.index([61, 32, 51, 78, 45]) ?
0
1
2
Error message
What is the output of Results.index(32) ?
1
[2] [1]
2 , 1
Error message
What is the output of Results[2].index(32) ?
1
[2] [1]
2
Error message
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)
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)
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] ?
9
[2, 4, 3]
[0, 3, 1]
Error message
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] ?
2
0
3
1
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] ?
3
Error message
12
8
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] ?
6
Error message
0
8
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] ) ?
1
Error message
0
2
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) ?
1
Error message
3, 1
[3] [1]
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) ?
1
Error message
3 , 1
[3] [1]
