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.
- # Lunch queue report
- names = ["Asha", "Ben", "Cara", "Dev", "Ella", "Femi", "Gus", "Hana"]
- orders = ["pizza", "salad", "pizza", "juice", "salad", "pizza", "juice", "salad"]
- prices = [3.5, 2.75, 3.5, 1.2, 2.75, 3.5, 1.2, 2.75]
- total = 0
- pizza_count = 0
- salad_count = 0
- juice_count = 0
- print("Lunch queue report")
- print("------------------")
- for i in range(len(names)):
- print(names[i], "ordered", orders[i])
- total = total + prices[i]
- if orders[i] == "pizza":
- pizza_count = pizza_count + 1
- if orders[i] == "salad":
- salad_count = salad_count + 1
- if orders[i] == "juice":
- juice_count = juice_count + 1
- print("Total takings:", total)
- print("Pizzas sold:", pizza_count)
- print("Salads sold:", salad_count)
- print("Juices sold:", juice_count)
- if pizza_count > 2
- print("Order more pizza dough")
- else:
- 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?
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.
It is one tool in the toolbox of a development environment. Which jobs are its jobs?
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
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?
Who types the line numbers in?
What happens to the numbers when a line is added or deleted?
Are line numbers part of the program code?
How does line numbering help in a long program?
An error message names a line. How do the numbers help?
What do error messages from translating or running code usually include?
Why are line numbers handy when you talk to another programmer?
Does line numbering find and fix the error for you?
Which tool shows the line numbers, and which reports the error's 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 postedMore Eduqas GCSE Computer Science topics
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.