levo

Problem Solving with Programming

Readable code, debugging and testing

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

Overview

Indentation, comments, identifiers and white space in Python, turning flowcharts into code, and finding and fixing syntax, logic and runtime errors.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Explain why indentation is essential in Python.

Key term

How is a comment written in Python, and why are comments used?

Key term

Why is score_total a better identifier than st?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Explain why indentation is essential in Python.

    Model answer

    Python uses indentation to show which lines belong to a block, such as the body of a loop. Wrong indentation changes what the code does or causes an error.

  2. 2

    How is a comment written in Python, and why are comments used?

    Model answer

    A comment starts with the # character, and Python ignores the rest of that line. Comments explain the purpose of the code to anyone maintaining it later.

  3. 3

    Why is score_total a better identifier than st?

    Model answer

    The name score_total says what the variable holds. A reader can follow the code without guessing what st stands for.

  4. 4

    How does white space make a program easier to read?

    Model answer

    Blank lines separate a program into logical sections. Spaces around operators make each line easier to scan.

  5. 5

    How do a flowchart’s decision box and loop-back arrow become Python code?

    Model answer

    A decision box becomes an if statement testing the same condition. A loop-back arrow becomes a while loop that repeats until the decision lets control move on.

  6. 6

    Explain what it means to refine a program.

    Model answer

    Refining a program means improving code that already works. The aim is clearer, shorter or more efficient code that gives the same results.

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.