ICT9 Review Worksheet
ICT9 Review Worksheet
REVIEW
Overview of lessons
Lesson Learning objectives
1 Warm up ● Write programs that display messages, receive keyboard input, and use
simple arithmetic expressions in assignment statements
● Use selection (if-elif-else statements) to control the flow of program
execution
● Locate and correct common syntax errors
● Create lists and access individual list items
3 In a while, ● Use iteration (while statements) to control the flow of program execution
crocodile ● Perform common operations on lists or individual items
● Perform common operations on strings or individual characters
4 The famous for ● Use iteration (for statements) to iterate over list items
● Perform common operations on lists or strings
5 Make a thing ● Use iteration (for loops) to iterate over lists and strings
● Use variables to keep track of counts and sums
● Combine key programming language features to develop solutions to
meaningful problems
Exercises
Q1. Read the Python program below:
When this program is executed, what will be displayed on the screen, as a result of executing
line 5?
Note: There may be errors in the program and/or it may not behave as expected.
A. 10
B. 1
C. It is impossible to determine in advance
D. There is an error in the program, because line 5 should have been indented
Q3. Read the Python program below:
1 pin = "2468"
2 correct = False
3 while correct == False:
4 print("Enter pin")
5 user = input()
6 if user == pin:
7 correct = True
8 print("Welcome")
When this program is executed, how many times will line 4 be executed?
A. Line 4 will be executed once.
B. Line 4 will be executed at least once.
C. Line 4 will be executed 2468 times.
D. Line 4 will be executed an infinite number of times (the while loop will never terminate).
Q4. Read the Python program below:
1 pin = "2468"
2 correct = False
3 while correct == False:
4 print("Enter pin")
5 user = input()
6 if user == pin:
7 print("Welcome")
When this program is executed, how many times will line 4 be executed?
A. Line 4 will be executed once.
B. Line 4 will be executed at least once.
C. Line 4 will be executed 2468 times.
D. Line 4 will be executed an infinite number of times (the while loop will never terminate).
Q5. Read the Python program below:
1 pin = "2468"
2 print("Enter pin")
3 user = input()
4 while user != pin:
5 print("Enter pin")
6 user = input()
7 print("Wrong pin, try again")
8 print("Welcome")
When this program is executed, what will be displayed on the screen after line 6 is executed and
the user types 2468 on the keyboard?
A. Wrong pin, try again C. Welcome
B. Wrong pin, try again D. Wrong pin, try again
Welcome Enter pin
a) When this program is executed, what will be displayed on the screen after the user types 6
on the keyboard?
.............................................................................
.............................................................................
b) When this program is executed, what will be displayed on the screen after the user types 0
on the keyboard?
......................................................................
......................................................................
.............................................................................
.............................................................................
.............................................................................
.............................................................................
When this program is executed, what will be displayed on the screen after the user types 10 on the
keyboard??
.............................................................................
10 season = 2
11 else:
12 season = 3
13 print("It is", seasons[season])
a) When this program is executed, what will be displayed on the screen after line 3 is executed
and the user types 2 on the keyboard?
.............................................................................
b) When this program is executed, what will be displayed on the screen after line 3 is executed
and the user types 5 on the keyboard?
...........................................................................
c) When this program is executed, what will be displayed on the screen after line 3 is executed
and the user types 9 on the keyboard?
....................................................................
d) When this program is executed, what will be displayed on the screen after line 3 is executed
and the user types 15 on the keyboard?
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
Page 3
1 planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn",
2 'Pluto']
3 print("Planets by 1930:")
4 print(planets)
5 planets.remove("Pluto")
6 print("Planets after 2006:")
7 print(planets)
......................................................................................
......................................................................................
......................................................................................
......................................................................................
......................................................................................
......................................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
......................................................................
Page 2
Q24. Read the Python program below:
.............................................................................
.............................................................................
......................................................................
......................................................................
What will be displayed on the screen when this program is executed after the user type in guitar and
drum?
.............................................................................
.............................................................................
Page 3
Q28. Read the Python program below:
What will be displayed on the screen when this program is executed and after the user type in guitar
and drum?
......................................................................
......................................................................
This program is created in order to repeatedly read the names of instruments and add them to a list.
What is correct?
A. the process is repeated forever
B. the process is repeated 3 times
C. the process is repeated for as long as the the list does not contain a guitar
D. the process is repeated for as long as the the list contains a guitar
Q30. Read the Python program below:
This program is created in order to repeatedly read the names of instruments and add them to a list.
What is correct?
A. the process is repeated forever
B. the process is repeated 3 times
C. the process is repeated for as long as the the list does not contain a guitar
D. the process is repeated for as long as the the list contains a guitar
Q31. Read the Python program below:
Page 4
1 shopping = ["Pasta", "Tomatoes", "Onions", "Basil"]
2 print("Buy:")
3 for item in shopping:
4 print(item)
.............................................................................
.............................................................................
.............................................................................
.............................................................................
.............................................................................
.............................................................................
......................................................................
......................................................................
Page 5
1 rolls = [1, 5, 3, 6]
2 selection = []
3 for dice in rolls:
4 if dice > 3:
5 selection.append(dice)
6 print(selection)
......................................................................
1 rolls = [1, 5, 3, 6, 2, 1]
2 selection = []
3 for dice in rolls:
4 if dice >= 5 or dice < 2:
5 selection.append(dice)
6 print(selection)
......................................................................
4 nb_words = len(dictionary)
7 length = int(input())
8 count = 0
10 if len(word) == length:
11 count = count + 1
print("There are", count, "words with", length, "letters")
What will be displayed on the screen when this program is executed after the user type 6 on the
keyboard?
......................................................................................
......................................................................................
......................................................................................
......................................................................................
......................................................................................
Page 6
Q37. Read the Python program below:
What will be displayed on the screen when this program is executed after the user type er on the
keyboard?
......................................................................
......................................................................
Page 7