Font size
WorksheetsPython Review
Total questions: 81
Worksheet time: 1hrs 7mins
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
#What is the output?
1,2,3,4,5
0,1,2,3,4
1,2,3,4
5,4,3,2,1
#How many hallos will be printed?
5
None
4
6
word= "computer"
for num in range(1,6):
print(word)
for number in range(6):
print(number)
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which of these will allow me to print all numbers from 0 to 4 ?
//0,1,2,3,4
for x in range(4):
print(x)
for x in range(0,4):
print(x)
for x in range(1,5):
print(x)
for x in range(5):
print(x)
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
For i in range(6):
print('Happy Python')
How many times Happy Python will be printed?
4
5
6
7
What are the syntax errors in this code?
:
Not indented
Both options
What is the output of range(1,10)
0123456789
123456789
1 to 10
012345
How many times does the following program print the word ‘computer’:
word= "computer"
for num in range(2,8):
print(word)
5
6
1
0
For i in range(4):
print('Happy Python')
How many times Happy Python will be printed?
4
5
6
7
What will be the output of this code?
Hi
3
Hi
3
Hi
Hi
Hi
What will be the output of this code?
2
4
6
12
What will be the output of this code?
2
4
6
12
What will be the output of this code?
1
3
4
5
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to £100.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a program that will keep letting me add a monthly payment for 12 months.
FOR Loop
WHILE Loop
numbers = [5, 14, 9, 17]
for number in numbers:
if number % 3 == 0:
print(number)
The output will be?
17
9
14
9
17
14
17
numbers = [5, 14 ,9, 17]
for number in numbers:
if number >= 9:
print (number)
The output will be?
17
9
14
9
17
14
17
print(str(i) * 5)
print("i" * i)
print("i" * i)
print(str(i) * i)
for number in range(6):
print(number)
word= "computer"
for num in range(1,6):
print(word)
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
Which of the following best describes the purpose of a for loop?
A for loop is for doing something an indeterminate number of times.
A for loop is doing something an infinite number of times.
A for loop is for doing something a fixed number of times.
A for loop is for doing something three times.
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print(i)
for i in range(3, 9, 2):
print(i)
for i in range(9):
print(i)
for i in range(3,9):
print(i)
What is the value of num when this loop completes?
num = 0
for i in range(2, 8, 2):
num += i
2
8
12
20
Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?
for i in range(0, 5):
for i in range(5):
for i in range(0, 5, 1):
for i in range(5, 0, 1):
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
drink_choices = ["coffee", "tea", "water", "juice", "soda"]
for drink in drink_choices:
print(drink)
"coffee"
["coffee", "tea", "water", "juice", "soda"]
drink
"coffee tea water juice soda"
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
numbers = [2, 4, 6, 8]
for number in numbers:
print("hello!")
2 hello! 4 hello! 6 hello! 8 hello!
hello!
2 4 6 8
hello! hello! hello! hello!
What will be the output after the following statements?
0
1
2
15
error
What will be the output after the following statements?
0
1
2
15
error
What will be the output after the following statements?
15
yes
equal
no
error
What will be the output after the following statements?
false
true
not false
not true
error
What will be the output after the following statements?
true
not false
false
not true
error
What will be the output after the following statements?
true
not false
false
not true
error
What will be the output after the following statements?
true
not false
false
not true
error
What will be the output after the following statements?
true
not false
false
not true
error
What will be the output after the following statements?
true
not false
false
not true
error
What output will be produced by the following segment of code?
Too Low
Too High
Syntax Error
No Output - Logic Error
Which symbol means "not equal to"?
==
<=
>=
!=
Which character must be at the end of the line for if?
:
;
.
{
True/False: The body of an "if" statement will only be executed if the condition is true.
True
False
print(Hello world!)
What is a Syntax Error?
A problem with the language ("grammar") used
A problem with the logical structure used
A problem with the version of Python used
A problem with the Operating System
What is Syntax?
Syntax is the word used to describe an error
Syntax is the rules of the programming language
It is used to read information
It is used to output information
When you have an error in your code what is the term used to define finding and fixing that error?
Error checking
Debugging
Syntax finder
Error finder
One of the lines contains at least one error.
Which line is it?
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
False
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
What will be the output for the following code?
i = 0
while i < 5:
print(i)
i = i + 1
1 2 3 4 5
0 1 2 3 4 5
1 2 3 4
0 1 2 3 4
What is the output for the following code?
i = 9
while i > 0:
print("Hello")
9
0
Infinite
8
