levo

Problem Solving with Programming

Lists, two-dimensional lists and records

  • 3 things to know
  • Paper 2
Start revising · £5/month

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.

Your recallNot started
Key term

How is an array represented in Python?

Key term

What is printed by scores = [12, 15, 9, 20], then print(scores[2])?

Key term

What does scores.append(7) do when scores = [12, 15, 9]?

Questions from this subtopic

Each one with the model answer underneath.

  1. 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. 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. 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. 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. 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. 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.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Computational Thinking
Data
Computers
Networks

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

The check is 45 + 27 = 72.
denarybinaryhexadecimal

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A kibibyte (KiB) is 1,024 bytes. The figure 1,024 is 2¹⁰.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Problem Solving with Programming, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.