Edexcel GCSE Computer Science 1CP2
Computational Thinking
Data
Computers
Networks
Issues and Impact
Problem Solving with Programming
Problem Solving with Programming
Lists, two-dimensional lists and records
- 3 things to know
- Paper 2
Overview
Python lists as arrays, append, insert and del, two-dimensional lists, records as lists of fields, and worked loops over lists of lists.
What you need to know
Answer each one before you reveal it.
What is printed by scores = [12, 15, 9, 20], then print(scores[2])?
What does scores.append(7) do when scores = [12, 15, 9]?
Questions from this subtopic
Each one with the model answer underneath.
- 1
How is an array represented in Python?
Model answer
Python represents an array as a list, such as scores = [12, 15, 9]. Each item is reached by an index that starts at 0.
- 2
What is printed by scores = [12, 15, 9, 20], then print(scores[2])?
Model answer
The code prints 9. Index 2 is the third item because indexes start at 0.
- 3
What does scores.append(7) do when scores = [12, 15, 9]?
Model answer
The list becomes [12, 15, 9, 7]. The append() method adds the item to the end.
- 4
What is the list after names = ["Ann", "Bo", "Cy"], then del names[1]?
Model answer
The list becomes ["Ann", "Cy"]. The del statement removes the item at index 1.
- 5
Give the list after nums = [4, 8, 12], then nums.insert(1, 6).
Model answer
The list becomes [4, 6, 8, 12]. The insert() method places 6 just before the item at index 1.
- 6
What is printed by print(len([3, 6, 9, 12, 15]))?
Model answer
The code prints 5. The len() function counts the items in the list.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Problem Solving with Programming, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.