GCSE · Computer Science · Eduqas · Spec C500QS
Refining code during development
Your program runs and prints something. Job done? Not even close: it can run perfectly and still do the wrong thing, or be a nightmare to read.
Computer Science · Refining code
It runs. But does it do what was asked?
A till program should do three things with the basket [4, 7, 5]: (1) add up every price; (2) take 2 off if the total is over 10; (3) print how many items were bought, then the total. Run each version, check the output against those requirements, then choose a fix for the marked line.
- prices = [4, 7, 5]
- total = 0
- for p in prices:
- total = p
- if total > 100:
- total = total - 2
- print("Items:", 0)
- print("Total:", total)
Every output shown is what Python prints when it runs this exact code. The basket prices are in pounds.
Computer Science · Reviewing code
Which review question is this?
Pick a finding, then pick the review question it answers.
Still to sort
How well it works (0)
Does it run all the way through and give correct results?
Where the line is: The program does try to do the job but gets the result wrong, or stops before it finishes. That is mainly about how well it works.
How readable it is (0)
Could someone else follow it and look after it? Think comments, program layout, identifiers and naming conventions.
Where the line is: The finding is about how the code looks or is named, not about what it does.
Whether it meets the functional requirements (0)
Does it do everything the requirements ask it to do?
Where the line is: The requirements ask for something and the program leaves it out. That is mainly about the functional requirements.
A reviewer has made eight notes about one program. Decide which of the three questions each note answers.
Computer Science · Functions and procedures
Follow the value through the call
Call each marked step in your head before the table shows it.
The main program calls one function and one procedure. Nothing is run here: every value is the lesson's. Commit to each marked step before it appears.
def add_postage(cost):new_cost = cost + 3return new_costdef show_total(amount):print("Pay: £" + str(amount))basket = 12bill = add_postage(basket)show_total(bill)
Variables
Step 1. basket is given the value 12. The def lines only describe the two subprograms; nothing inside them happens until the main program calls them. This first step is worked for you.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
A program that runs isn't finished. Here's how you make it better.
What you need to know
- Refining code means finding improvements and making them. A program that runs is not automatically finished.
- Reviewing code checks how well it works, how readable it is and whether it meets the functional requirements.
Have a goYour mate says: 'It ran, so it's done!' Name one of the three review checks that 'it ran' doesn't cover.
How readable it is, or whether it meets the functional requirements.
Running shows the program did something. It can still be hard to read, or leave out something the requirements ask for.
- Review against the functional requirements to see what the code doesn't do yet, then adapt it step by step.
- Improving code may mean simplifying logic, breaking large sections into subprograms, or correcting errors.
- Readable, maintainable code lets others understand it and work with it; comments, program layout, identifiers and naming conventions all help.
Have a goA program keeps a customer's age in a variable called x. Suggest a better identifier.
customer_age, or any clear name that says what the variable holds.
A name that says what the variable holds helps anyone who reads or maintains the code understand it easily.
- Modularity is breaking software into independent, self-contained modules; in structured programming these are subprograms, each doing one specific task.
- Write repeated code once in a subprogram, then call it whenever it is needed.
- More modular code brings readability, easier testing, easier maintenance, faster development time and reduced repetition.
- A function differs from a procedure because it returns a value to the main program, using a return statement.
Have a goA subprogram prints 'Hello' on the screen and has no return statement. Function or procedure?
A procedure.
Printing is not returning: nothing is sent back to the main program, and returning a value is what makes a function different.
- Parameters hold the values a function needs, as local variables; the arguments in the call are passed in through them.
The big picture
Working code isn't finished code. Refining means reviewing a program for how well it works, how readable it is and whether it meets the functional requirements, then improving it step by step. Dividing it into subprograms (functions and procedures, with parameters, arguments and return values) makes it easier to read, test, maintain and develop.
Key points
Worked example
Problem
This program should print the larger of two scores, 8 and 5. It prints 5. Refine it. score_one = 8 score_two = 5 if score_one < score_two: print(score_one) else: print(score_two)
⚠ Watch out
Thinking that if a program runs, it is finished. A program can run and still miss something the functional requirements ask for, or be hard for anyone else to read.
Memory hook
Three questions before you say 'done': does it WORK, can others READ it, and is it what was REQUIRED? If it only runs, it's only a draft.
Check yourself
Without looking back: say the three questions a review asks, then pick a program you have written and name one change you would make to it next.
Flashcards
(13)What does refining code mean?
What three things does reviewing code check?
Name three ways code can be improved.
Why should code be readable and maintainable?
Which good programming practices make code easier to read?
What is modularity?
What is structured (modular) programming?
How do subprograms reduce repeated code?
Name the five benefits of improving modularity.
How is a function different from a procedure?
What do parameters do?
How do you call a function, and where do the arguments go?
When does a function need a return statement?
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
- Iteration: condition and counter controlled loops
- Lists, tuples and dictionaries
- Mathematical and logical operations in code
- Modular structuring with abstraction
- Presenting test outcomes with commentary
- Program a solution to requirements
- Selection in programs
- Sequence in programs
- String manipulation in code
- Subroutines with well-defined interfaces
- Typical, extreme and erroneous test data
- Understanding revised requirements
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 16 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.