GCSE · Computer Science · Eduqas · Spec C500QS
Libraries
Can you use code you have never seen? Yes, and programmers do it all the time. Have a go at calling it, then find out why it works.
Computer Science · Libraries
Use code you have never seen
Toolbox is a made-up library. Its interface is in the first lines of the program. Call each result before it appears.
Step through the program. At each marked call, say what comes back using only the interface. Nothing is run: every value is the lesson’s.
// Toolbox: an illustrative library. Its interface is all you get.// toolbox.larger(a, b) gives back the bigger of two numbers// toolbox.upper(text) gives back text in capital letters// toolbox.count_chars(text) gives back how many characters text hasimport toolboxfirst = int(input("First number: "))second = int(input("Second number: "))word = input("A word: ")best = toolbox.larger(first, second)loud = toolbox.upper(word)size = toolbox.count_chars(loud)print(loud)print(best + size)
Variables
(no variables yet)
Step 1. import toolbox makes the library’s subroutines available to this program. You are only ever shown their interface, never the code inside them.
You will never be shown how larger, upper or count_chars work inside. You will not need to be.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Code someone else already wrote, and why you can use it without ever opening it
What you need to know
- Libraries are one of the software tools a programmer can use in a development environment.
- A library is a collection of pre-written code, such as subroutines (functions and procedures), that a program can use.
- Instead of writing that code from scratch, a programmer uses the library’s code in their own program.
Have a goZed insists: “A library is a building where finished programs are stored.” Fix his sentence using what you just read.
It is a collection of pre-written code, such as subroutines, that you use inside your own program.
A library is code you call from your program, not a place and not a shelf of finished programs.
- To call a library subroutine, you need only its name, its inputs and its outputs.
- How the code inside works? You don’t need to know. That’s the whole point.
Have a goA library subroutine reverse(text) is described as “gives back the letters of text in reverse order”. What does reverse("pots") give back?
stop
The name, input and output were enough. You never needed to see the code inside reverse.
- Using a library saves time, because the code already exists and doesn’t have to be written again.
- Library code can be reused in many different programs.
- Library code has usually already been tested, so it can reduce the errors a programmer introduces.
- “Reduce” is not “remove”: library code is not guaranteed to be error-free.
Have a goPriya says: “It’s library code, so it’s guaranteed bug-free.” Which two words in the bullets above does she ignore?
“Usually” and “reduce”
Library code has usually been tested, which can reduce errors; it is not a guarantee that there are none.
The big picture
A library is a collection of pre-written code, such as subroutines. It is one of the software tools available to a programmer. You call its subroutines by name, inputs and outputs, and using it saves time, lets code be reused and usually means the code is already tested.
Key points
Worked example
Problem
A library describes two subroutines. smallest(a, b) gives back the smaller of two numbers. double(n) gives back n multiplied by 2. Using only those descriptions, what does print(smallest(8, 3) + double(5)) show?
⚠ Watch out
Treating “usually already tested” as “never wrong”. Library code can reduce the errors you introduce, but it is not guaranteed error-free, and you can still call it wrongly.
Memory hook
Think of a kettle: you know what goes in (water, a flick of the switch) and what comes out (hot water), and you never need to know the wiring. A library subroutine is the same: name, inputs, outputs. Use the outside, ignore the inside.
Check yourself
A friend says she can’t call toolbox.upper("hello") until she has read its code. Tell her what she does need to know, what she doesn’t, and one benefit of library code.
Flashcards
(11)Where do libraries sit among a programmer’s tools?
What is a library?
Name the two kinds of subroutine a library can hold.
A programmer wants to call a library subroutine. What do they need to know?
Does a programmer need to know how a library subroutine’s code works inside?
What does using a library let a programmer avoid?
Why does using a library save time?
What does “reuse” mean for library code?
Why can library code reduce errors?
True or false: library code is guaranteed to be error-free.
True or false: a library is a store of finished programs.
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.