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 has
import toolbox
first = 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.

Step 1 of 9Called right: 0 of 4

You will never be shown how larger, upper or count_chars work inside. You will not need to be.

Where a library sits

Zoom in on a library

Level 1 of 4: Development environment

Predict first

A programmer is working in a development environment. Where do you think libraries fit?

  • Frames are not drawn to scale.
  1. Where a programmer develops software. It makes a set of software tools available to them.

Two ways to get a job done

Writing it from scratchvsCalling it from a library

Same job, two routes. Compare them row by row.

Focus

Time taken

Writing it from scratch

You write every line yourself, so you spend the time writing it.

Calling it from a library

The code already exists, so you just call it. That saves the programmer time.

The insight

The time saved is writing time. The code is already written and does not have to be written again.

Does the code exist yet?

Writing it from scratch

No. You start with nothing.

Calling it from a library

Yes. It is pre-written and can be used in your program.

Testing

Writing it from scratch

Nobody has tested it until you do.

Calling it from a library

It has usually already been tested.

What you need to know about the inside

Writing it from scratch

All of it, because you wrote the inside.

Calling it from a library

Just each subroutine’s name, inputs and outputs.

Reuse

Who calls which subroutine?

Toolbox and these three programs are all made up. For each subroutine, tick every program you think would call it. Then check.

  • A Quiz program
  • B Shop till program
  • C Score board program
  1. larger(a, b)
  2. upper(text)
  3. count_chars(text)
  4. round_to(n, places)

Exam line: The same library code can be reused in many different programs.

What do you really think?

Library code: which idea is closest to yours?

Three students are talking about library code before a project.

Which is closest to what you think right now?
How sure are you?

Exam line: Library code is pre-written and usually already tested, so it can reduce, not remove, the errors a programmer introduces.

Exam-style question

Write it, then mark it

Give three benefits to a programmer of using a library when developing software. [3 marks]

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

Exam line: Name each benefit and give its reason. A bare label rarely says enough.

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

1A library is a collection of pre-written code, such as subroutines (functions and procedures).
2Libraries are one of the software tools available to a programmer in a development environment.
3To use a library subroutine, you only need its name, inputs and outputs, not how its code works inside.
4Benefits: it saves time, the same code can be reused in many programs, and it has usually already been tested.

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?
Libraries are one of the software tools available to a programmer in a development environment.
What is a library?
A collection of pre-written code, such as subroutines, that can be used in a program.
Name the two kinds of subroutine a library can hold.
Functions and procedures.
A programmer wants to call a library subroutine. What do they need to know?
Its name, its inputs and its outputs.
Does a programmer need to know how a library subroutine’s code works inside?
No. They only need to know how to call it.
What does using a library let a programmer avoid?
Writing that code from scratch.
Why does using a library save time?
The code already exists, so it does not have to be written again.
What does “reuse” mean for library code?
The same library code can be used in many different programs.
Why can library code reduce errors?
It has usually already been tested, so the programmer introduces fewer errors than by writing it themselves.
True or false: library code is guaranteed to be error-free.
False. It has usually been tested, which can reduce errors, but there is no guarantee.
True or false: a library is a store of finished programs.
False. It is a collection of pre-written code, such as subroutines, used inside your own program.

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.