Summative Assessment Answers - Python Programming With Sequences of Data - Y9
Summative Assessment Answers - Python Programming With Sequences of Data - Y9
Summative Assessment Answers - Python Programming With Sequences of Data - Y9
Assessment – Answers
Assessment answers
Task
The partial program below creates a list of the days of the week and assigns it to days.
Question 1: If the lines below were added to the program, what would the program
output be?
4 item = days[3]
5 print(item)
Answer Thursday
Question 2: If the lines below were added to the program, what would the program
output be?
4 index = 1
5 item = days[index+1]
6 print(index, item)
Answer 1 Wednesday
Teacher note: The value of index is also printed to make sure the learners don’t think
that index has not been incremented.
Question 3: Fill in the gaps in the code below, so that the items in the list of days are
displayed on the screen:
Task
Read the program below:
Question 1: If the user types 1 on the keyboard, what will be the output of this program
when it is executed?
Answer It’s a rocky planet
Teacher note: The objective is not to assess knowledge of zero-based indices again. The
answer will be the same regardless of whether the learner thinks that the planet is
Mercury or Venus.
Question 2: If the user types 3 on the keyboard, what will be the output of this
program when it is executed?
Answer The second letter is a
Teacher note: The objective is not to assess knowledge of zero-based indices again. The
answer will be the same regardless of whether the learner thinks that the planet is Earth
or Mars.
Question 3: Suppose that the elif in line 8 is modified to an if. If the user types 1 on the
keyboard, what will be the output of this program when it is executed?
Page 2 12-05-2021
Year 9 – Python programming with sequences of data
Assessment – Answers
Question 4: The ‘rocky planets’ are the first four planets of the solar system. How
would you modify the program so that all planets are correctly classified (i.e. the
message “It’s a rocky planet” is displayed for all four of them).
Answer Change the condition in line 6 to index < 4 or index <= 3.
Task
Read the program below and answer the questions. You can use the reference table at
the bottom of the page to see how the index method works.
1 alphabet = 'abcdefghijklmnopqrstuvwxyz'
2 letter = 'c'
3 position = alphabet.index(letter)
4 print(position)
Question: The program below is an extension of the previous one. Fill in the gaps, so
that the program prompts the user to enter a word and then iterates over each letter in
the word to display its position in the alphabet.
1 alphabet = 'abcdefghijklmnopqrstuvwxyz'
2 print("Enter a word:")
3 word = input()
4 for letter in word :
5 position = alphabet.index(letter)
6 print(position)
Reference table
Page 3 12-05-2021
Year 9 – Python programming with sequences of data
Assessment – Answers
Task
The program below converts a binary number to its decimal equivalent. The questions
that follow do not require you to understand how it works.
1 binary = input()
2 decimal = 0
3 weight = 1
4 for digit in reversed(binary):
5 if digit == '1':
6 decimal = decimal + weight
7 weight = 2 * weight
8 print(binary, "=", decimal)
Question 2: Locate the line of code where program execution is suspended until the
user enters a value on the keyboard.
Line 1 (due to input)
Question 3: Locate the line of code that contains a condition (a logical expression).
Line 5 (the condition is: digit == ‘1’)
Question 4: Locate the line of code that doubles the value of a variable.
Line 7 (the assignment is weight = 2 * weight)
Question 5: Locate the lines of code that may be executed more than once.
Page 4 12-05-2021
Year 9 – Python programming with sequences of data
Assessment – Answers
Task
Read the program below and answer the questions. The reference table after the
questions shows you how the append and pop methods work.
1 days = []
2 while len(days) < 12:
3 days.append(31)
4 days.append(30)
5 days[1] = 28
6 days.pop()
7 days.insert(7, 31)
Question 1: What will be the contents of the days list, after lines 1 to 4 of the program
have been executed?
Answer [31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30]
Question 2: What will be the contents of the days list, after line 5 of the program has
been executed?
Write the items of the list, or describe how the list will change with respect to your previous
answer.
Answer [31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30]
The value of the second item becomes 28.
Page 5 12-05-2021
Year 9 – Python programming with sequences of data
Assessment – Answers
Question 3: What will be the contents of the days list, after line 6 of the program has
been executed?
Write the items of the list, or describe how the list will change with respect to your previous
answer.
Answer [31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31]
The last item (30) has been removed from the list.
Question 4: What will be the contents of the days list, after line 7 of the program has
been executed?
Write the items of the list, or describe how the list will change with respect to your previous
answer.
Answer [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
A new item (31) has been inserted as the 8th item in the list (with index 7).
Teacher note: The objective is to assess understanding of the insert method, not to
assess knowledge of zero-based indices again. The answer will be the same regardless
of whether the learner inserts at position 7 or 8.
Reference table
e.g. numbers.append(42)
Resources are updated regularly - the latest version is available at: the-cc.io/curriculum.
Page 6 12-05-2021