GCSE · Computer Science · Eduqas · Spec C500QS

Automatic line numbering

Your program has 200 lines, the translator says there is a problem on line 137, and you have no idea where that is. Meet the tool that fixes that.

Computer Science · Editors and IDEs

Which line is the translator talking about?

Here is a 32-line program in a code editor, with the line numbers switched off. Press Run and read what the translator says. Then find the line it names: first by counting down the lines by eye, then with the Line numbers switch on. Finally choose the fix for that line and run it again.

Notice what the switch changes, and what it never touches.

Python
  1. # Lunch queue report
  2. names = ["Asha", "Ben", "Cara", "Dev", "Ella", "Femi", "Gus", "Hana"]
  3. orders = ["pizza", "salad", "pizza", "juice", "salad", "pizza", "juice", "salad"]
  4. prices = [3.5, 2.75, 3.5, 1.2, 2.75, 3.5, 1.2, 2.75]
  5. total = 0
  6. pizza_count = 0
  7. salad_count = 0
  8. juice_count = 0
  9. print("Lunch queue report")
  10. print("------------------")
  11. for i in range(len(names)):
  12. print(names[i], "ordered", orders[i])
  13. total = total + prices[i]
  14. if orders[i] == "pizza":
  15. pizza_count = pizza_count + 1
  16. if orders[i] == "salad":
  17. salad_count = salad_count + 1
  18. if orders[i] == "juice":
  19. juice_count = juice_count + 1
  20. print("Total takings:", total)
  21. print("Pizzas sold:", pizza_count)
  22. print("Salads sold:", salad_count)
  23. print("Juices sold:", juice_count)
  24. if pizza_count > 2
  25. print("Order more pizza dough")
  26. else:
  27. print("Stock is fine")

Python 3.13. The message is the one Python gives for this exact code.

Predict, then check

Commit to one answer before you look.

A short program has four lines, numbered 1 to 4 by the editor. Line 1 is name = "Sam", line 2 is age = 15, line 3 is print(name) and line 4 is print(age). You insert a new line, city = "Leeds", straight after line 2. What number does print(age) show now?

Check what you think

What are those numbers, really?

A friend has just started programming. They are looking at the numbers down the left-hand side of their editor and ask you what they are.

Which of these is closest to what you would tell them?
How sure are you?

Exam line: Line numbers are displayed by the editor; they are not part of the code and do not change how it runs.

Computer Science · Editors and IDEs

What is line numbering for?

Pick a situation, then decide: is this something automatic line numbering does for the programmer, or not?

Still to sort

Line numbering helps here (0)

It makes a line easier to find or to point at.

Where the line is: If the job is getting to a line or naming a line, the numbers are what help.

Not what line numbering does (0)

It leaves the code, the mistake or the running of the program alone.

Where the line is: If the job is changing, correcting or running code, that is not the numbers.

6 of 6 still to sort.

It is one tool in the toolbox of a development environment. Which jobs are its jobs?

Exam line: Line numbering helps you find and refer to lines; it does not do the fixing, and it does not change the running of the program.

Have a go

Write it, then mark it

Explain how automatic line numbering helps a programmer. [3 marks]

0 words · your answer stays on this page and is not sent anywhere.

Exam line: Give separate points: find a line quickly, go to the line in an error message, refer precisely to a line.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

The editor numbers your lines so you can jump straight to the one that matters.

What you need to know

  • Automatic line numbering is one of the tools a development environment (such as an IDE) gives a programmer to help them write code.
  • Switch it on and the code editor shows a number next to each line, counting upwards from the first line.
  • Nobody types those numbers. The development environment generates them automatically.
  • Have a goYour friend has typed 1, 2, 3 and so on at the start of all 200 lines 'to help the editor'. Kindly, what do you tell them?

    The editor already numbers every line for you, so there is nothing to type.

    The numbers are generated automatically by the development environment, so typing them by hand is wasted effort.

  • Add a line and every line below it gets a number one higher. Delete one and each line below gets a number one lower.
  • Have a goA 10-line program has line 4 deleted. What number does the old line 10 show afterwards?

    9

    Deleting a line gives every line below it a number one lower, and the editor updates the numbers by itself.

  • The numbers are shown by the editor only. They are not part of the program code and do not change how it runs.
  • In a long program, a line with a number is quicker and easier to find than one you have to hunt for.
  • Error messages from translating or running code usually say which line the problem was detected on.
  • With numbers showing, you can go straight to that line to locate and fix the error.
  • Line numbers also let you point at one exact line, for example when explaining a problem to another programmer.
  • Have a goYou message a teammate: 'The bug is somewhere near the top.' What could you give them instead that points at exactly one line?

    A line number, for example 'line 37'.

    Line numbers are a precise way to refer to a particular line, where 'near the top' leaves your teammate searching.

The big picture

Automatic line numbering is a development environment tool: the editor numbers every line for you, keeps the numbers right as lines change, and shows them without making them part of the program. Programmers use the numbers to find a line quickly in a long program, to go straight to the line an error message names, and to refer to a line precisely.

Key points

1Automatic line numbering is a development environment tool: the editor shows a number beside each line, counting upwards from the first.
2The development environment generates and updates the numbers, so the programmer never types them.
3The numbers are displayed by the editor only: they are not part of the code and do not change how the program runs.
4They help the programmer find a line quickly, go straight to the line an error message names, and refer precisely to a line.

Worked example

Problem

A programmer runs a 120-line program. The translator reports: NameError: name 'totl' is not defined. Did you mean: 'total'? and says the problem is on line 48. Show how line numbering gets them from message to fix.

⚠ Watch out

Thinking line numbering finds or fixes the mistake. The message names the line and the numbers get you there, but you still read the line, work out what is wrong and fix it yourself.

🧠

Memory hook

Number, jump, point: the editor numbers the lines, you jump to the line the message names, and you point at a line when you talk to someone else.

✓

Check yourself

An error message says line 73. In one sentence each: what do the line numbers let you do, and what can't they do?

Flashcards

(10)
What is automatic line numbering?
A tool in a development environment (such as an IDE). The code editor shows a number next to each line, counting upwards from the first line.
Who types the line numbers in?
Nobody. The development environment generates them automatically.
What happens to the numbers when a line is added or deleted?
They update automatically, so the numbers stay correct.
Are line numbers part of the program code?
No. The editor displays them only, and they do not affect how the program runs.
How does line numbering help in a long program?
It makes a particular line quicker and easier to find.
An error message names a line. How do the numbers help?
You can go straight to that line to locate and fix the error.
What do error messages from translating or running code usually include?
The line number where the problem was detected.
Why are line numbers handy when you talk to another programmer?
They are a precise way to refer to one particular line.
Does line numbering find and fix the error for you?
No. The message names the line and the numbers get you there. Fixing it is the programmer's job.
Which tool shows the line numbers, and which reports the error's line?
The development environment's editor shows the numbers. The error message, produced when code is translated or run, states the line.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 15 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.