0% found this document useful (0 votes)
14 views13 pages

ICT9 Review Worksheet

This document contains a review of lessons on Python programming with sequences of data for Year 9 students. It includes an overview of 5 lessons covering topics like lists, strings, conditionals and iteration. It also contains 16 multiple choice questions testing understanding of Python concepts like variables, operators, conditionals, loops and lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views13 pages

ICT9 Review Worksheet

This document contains a review of lessons on Python programming with sequences of data for Year 9 students. It includes an overview of 5 lessons covering topics like lists, strings, conditionals and iteration. It also contains 16 multiple choice questions testing understanding of Python concepts like variables, operators, conditionals, loops and lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ICT Year 9 – Python programming with sequences of data

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

2 Playlist ● Perform common operations on lists or individual 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:

1 from random import randint


2 number = randint(1,10)
3 while number != 10:
4 print(number)
5 number = randint(1,10)

How many times will line 4 be executed?


Note: There may be errors in the program and/or it may not behave as expected.
A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 10
D. It is impossible to determine in advance
E. Infinitely (the condition in line 2 will never become False)
Q2. Read the Python program below:

1 from random import randint


2 number = randint(1,10)
3 while number != 10:
4 number = randint(1,10)
5 print(number)

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

Q6. A set of precise instructions that is meant to solve a problem is .


A. a computer
B. an algorithm
C. a program
D. an interpreter

Q7. The instructions in an algorithm .


A. can be expressed in any language
B. can be expressed in any language, as long as they are precise
C. can only be expressed using a programming language
D. can only be expressed using binary digits

Q8. The instructions in an algorithm, when expressed precisely in English, .


A. can only be carried out by humans
B. can only be carried out by computers
C. can be carried out by both humans and computers

Q9. The instructions in a program, when expressed in Python, .


A. can only be carried out by humans, as long as they understand Python
B. can only be carried out by computers
C. can be carried out by computers, as long as an interpreter is available
D. can be carried out by humans, as long as they understand Python, and computers, as long
as an interpreter is available
Q10. The instructions in a program .
A. can be expressed in any language
B. can be expressed in any language, as long as they are precise
C. can only be expressed using a programming language
D. can only be expressed using binary digits
Q11. A Python program requires to be executed.
A. a computer
B. a program called ‘the Python translator’
C. a program called ‘the Python interpreter’
D. a program called ‘a development environment’

Q12. Match Python components with their description.


1. input A. perform actions repeatedly
2. print B. display to the screen
3. while C. check a condition, to select which actions to perform
4. if D. read from the keyboard
5. = E. assign a value to a variable

Q13. Identify the following components in the given program:


1 a = int(input()) Terminologies Components
2 b = int(input())
arithmetic expression e.g., b + a / 2
3 avg = b + a / 2
4 print(avg) variables
5 max = a
6 if b > max: assignment statements
7 max = b
8 print(max)
Boolean expression
(condition)
a block of statements
that may not be
executed

Q14. Read the Python program below:


1 print("What day is it today?")
2 day = int(input())
3 if day < 4:
4 print("It’s a weekday")
5
remaining = 5 - day
6
print(remaining, "days until the weekend")
7
elif day == 4:
8
9 print("It’s Friday")

10 print("Just a day left until the weekend")


11 else:
12 print("It’s the weekend!")

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?

......................................................................

......................................................................

Q15. Read the Python program below:

1 months = ["January", "February","March", "April", "May",


2 "June", "July", "August", "September", "October",
3 "November","December"]
4 print("These are the summer months:")
5
print(months[5])
6
print(months[6])
7
print(months[7])
8

When this program is executed, what will be displayed on the screen?

.............................................................................

.............................................................................

.............................................................................

.............................................................................

Q16. Read the Python program below:


1 months = ["January", "February","March", "April", "May",
2 "June", "July", "August", "September", "October",
3 "November","December"]
4 print("What month is it? (1-12)")
5
month = int(input())
6
print("It is", months[month-1])

When this program is executed, what will be displayed on the screen after the user types 10 on the
keyboard??

.............................................................................

Q17. Read the Python program below:

1 seasons = ["Winter", "Spring", "Summer", "Autumn"]


2 print("What month is it? (1-12)")
3 month = int(input())
4 if month <= 2 or month == 12:
5
season = 0
6
elif month <= 5:
7
season = 1
8
9 elif month <= 8:

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?

......................................................................

Q18. Read the Python program below:


Page 2
1 planets = ["Mercury", "Venus", "Earth", "Mars",
2 "Jupiter", "Saturn","Uranus", "Neptune"]
3 position = 3
4 object = planets[position]
5 print(object)

What will be displayed on the screen when this program is executed?

......................................................................

......................................................................

Q19. Read the Python program below:

1 planets = ["Mercury", "Venus", "Earth", "Mars",


2 "Jupiter", "Saturn","Uranus", "Neptune"]
3 position = planets.index("Venus")
4 print(position)

What will be displayed on the screen when this program is executed?

......................................................................

......................................................................

Q20. Read the Python program below:

1 planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn"]


2 print("Planets in antiquity:")
3 print(planets)
4 planets.append("Uranus")
5 planets.append("Neptune")
6 planets.append("Pluto")
7 print("Planets by 1930:")
8 print(planets)

What will be displayed on the screen when this program is executed?

......................................................................

......................................................................

......................................................................

......................................................................

......................................................................

Q21. Read the Python program below:

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)

What will be displayed on the screen when this program is executed?

......................................................................................

......................................................................................

......................................................................................

......................................................................................

......................................................................................

......................................................................................

Q22. Read the Python program below:

1 dwarves = ["Ceres", "Ataecina", "Eris", "Makemake"]


2 dwarves[1] = "Haumea"
3 print("Dwarf planets:")
4 print(dwarves)

What will be displayed on the screen when this program is executed?

......................................................................

......................................................................

......................................................................

Q23. Read the Python program below:

1 dwarves = ["Ceres", "Ataecina", "Eris", "Makemake"]


2 dwarves[1] = "Haumea"
3 dwarves.insert(1, "Pluto")
4 print("Dwarf planets:")
5 print(dwarves)

What will be displayed on the screen when this program is executed?

......................................................................

......................................................................

......................................................................

Page 2
Q24. Read the Python program below:

1 dwarves = ["Ceres", "Ataecina", "Eris", "Makemake"]


2 length = len(dwarves)
3 print(length)
4 dwarves.insert(1, "Pluto")
5 length = len(dwarves)
6 print(length)

What will be displayed on the screen when this program is executed?

.............................................................................

.............................................................................

Q25. Read the Python program below:

1 planets = ["Mercury", "Venus", "Earth", "Mars",


2 "Jupiter", "Saturn","Uranus", "Neptune"]
3 status = "Pluto" in planets
4 print(status)

What will be displayed on the screen when this program is executed?

......................................................................

Q26. Read the Python program below:

1 planets = ["Mercury", "Venus", "Earth", "Mars",


2 "Jupiter", "Saturn","Uranus", "Neptune"]
3 status = not "Pluto" in planets
4 print(status)

What will be displayed on the screen when this program is executed?

......................................................................

Q27. Read the Python program below:

1 print("Let's form a band")


2 band = ['piano']
3 while len(band) < 3:
4 print("Pick an instrument:")
5 instrument = input()
6 band.append(instrument)
7 print(band)

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:

1 print("Let's form a band")


2 band = []
3 print("Pick an instrument:")
4 instrument = input()
5 while len(band) < 3:
6 band.append(instrument)
7 print(band)

What will be displayed on the screen when this program is executed and after the user type in guitar
and drum?

......................................................................

......................................................................

Q29. Read the Python program below:

1 print("Let's form a band")


2 band = []
3 while not "guitar" in band:
4 print("Pick an instrument:")
5 instrument = input()
6 band.append(instrument)
7 print(band)

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:

1 print("Let's form a band")


2 band = []
3 while not "guitar" in band:
4 print("Pick an instrument:")
5 instrument = input()
6 band.append(instrument)
7 print(band)

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)

What will be displayed on the screen when this program is executed?

.............................................................................

.............................................................................

.............................................................................

.............................................................................

.............................................................................

.............................................................................

Q32. Read the Python program below:

1 shopping = ["Pasta", "Tomatoes", "Onions", "Basil"]


2 count = 0
3 print("Buy:")
4 for item in shopping:
5 count = count + 1
6 print(count)

What will be displayed on the screen when this program is executed?

......................................................................

Q33. Read the Python program below:

1 shopping = ["Pasta", "Tomatoes", "Onions", "Basil"]


2 count = 0
3 print("Buy:")
4 for item in shopping:
5 if len(item) > 5:
6 count = count + 1
7 print(count)

What will be displayed on the screen when this program is executed?

......................................................................

Q34. Read the Python program below:

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)

What will be displayed on the screen when this program is executed?

......................................................................

Q35. Read the Python program below:

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)

What will be displayed on the screen when this program is executed?

......................................................................

Q36. Read the Python program below:

1 dictionary = ['apple', 'banana', 'cactus', 'dog', 'egg', 'flower',


2 'greatest', 'heuristic', 'indicator', 'juvelin', 'kite', 'laser',
3 'monochrome', 'negative', 'octave', 'pharming', 'query']

4 nb_words = len(dictionary)

5 print(nb_words, " words in the list")

6 print("Length of words to search for:")

7 length = int(input())

8 count = 0

9 for word in dictionary:

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:

1 dictionary = ['apple', 'banana', 'cactus', 'dog', 'egg', 'flower',


2 'greatest', 'heuristic', 'indicator', 'juvelin',
3 'kite', 'laser', 'monochrome', 'negative', 'octave',
4 'pharming', 'query']
5 print("Text to search for:")
6 searchString = input()
7 collectedWords = []
8 for word in dictionary:
9 if searchString in word:
10 collectedWords.append(word)
11 for word in collectedWords:
12 print(word)

What will be displayed on the screen when this program is executed after the user type er on the
keyboard?

......................................................................

......................................................................

Page 7

You might also like