NEW
Font size
S
M
L
XL
WorksheetsPython - Loops & Lists
Total questions: 15
Worksheet time: 9mins
Name
Class
Date
1.
What is the word used to describe repetition in programming?
a)
Sequence
b)
Selection
c)
Iteration
d)
Coding
2.
What are the two main types of loops that we have learned about in Python?
a)
IF Function & Variables
b)
FOR and WHILE Loops
c)
Forever and Fixed Loop
d)
Data Types and Numbers
3.
What type of loop is used when you know how many times you want to repeat something?
a)
A WHILE Loop
b)
An IF function
c)
A FOR Loop
d)
A Variable
4.
What type of loop is used when you DO NOT know how many times you want to repeat something?
a)
A WHILE Loop
b)
A Counter
c)
A FOR Loop
d)
A Forever Loop
5.
What would amount equal in this piece of code:
amount = 2 + 5 * 2
amount = 2 + 5 * 2
a)
12
b)
9
c)
14
d)
5
6.
What would be the value of ‘marks’ after running this code:
marks = 20
total = 5
newmarks = marks * 3
marks = 20
total = 5
newmarks = marks * 3
a)
60
b)
45
c)
100
d)
75
7.
What is printed when this program is run:
days = 5
if days > 6:
print(“Month”)
else:
print(“Week”)
days = 5
if days > 6:
print(“Month”)
else:
print(“Week”)
a)
Month
b)
Week
c)
Day
d)
4
8.
What letter will be printed on the screen after running this code:
team = “Manchester United”
letter = name[5]
print(letter)
team = “Manchester United”
letter = name[5]
print(letter)
a)
M
b)
d
c)
e
d)
Nothing prints
9.
What will be printed after running this FOR loop:
for number in range(6):
print(number)
for number in range(6):
print(number)
a)
The number 6
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
10.
How many times does the following program print the word ‘computer’:
word= "computer"
for num in range(1,6):
print(word)
word= "computer"
for num in range(1,6):
print(word)
a)
5
b)
6
c)
1
d)
0
11.
Look at the code below and identify which of the statements below are true:
for loopCounter in range(10,101,10):
print(loopCounter)
for loopCounter in range(10,101,10):
print(loopCounter)
a)
Starts at 10, goes up to 100, increases by 10
b)
Starts at 10, goes upto 101, increases by 10
c)
Starts at 1, goes upto 100, increases by 1
d)
Starts at 10, goes upto 10, increases by 10
12.
What will the following code result in:
name = “Alison”
number = len(name)
print(number)
name = “Alison”
number = len(name)
print(number)
a)
4
b)
5
c)
6
d)
7
13.
In the following code what will happen if the wrong password is entered:
while password != "computer":
print("Enter Password: ")
password = input()
while password != "computer":
print("Enter Password: ")
password = input()
a)
It will log in
b)
It will keep asking to type in password
14.
What is the position of the name 'Paula' in the following list:
names = ["Paul","Phillip","Paula","Phillipa"]
names = ["Paul","Phillip","Paula","Phillipa"]
a)
0
b)
1
c)
2
d)
3
15.
What does the APPEND procedure do in the following code:
teams = [“Man Utd”,“Man City”,"Arsenal"]
teams.append(“Liverpool”)
teams = [“Man Utd”,“Man City”,"Arsenal"]
teams.append(“Liverpool”)
a)
Deletes Liverpool from the list
b)
Adds Chelsea to the list
c)
Removes Arsenal from the list
d)
Adds Liverpool the list
Reset
