Library Routines (CIE IGCSE Computer Science)

Revision Note

Test Yourself
Becci Peters

Expertise

Computer Science

Library Routines

Library routines are pre-written code that can be used in programs to perform specific tasks.

  • Using library routines saves time by not having to write code from scratch
  • Library routines are also tested and proven to work, so errors are less likely
  • Some commonly used library routines include:
    • Input/output routines
    • Maths routines
  • Libraries can be included in programs by importing them
  • The specific syntax for importing a library may vary depending on the programming language being used
  • It is important to check the documentation for a library to understand its usage and available functions

Maths routines

  • MOD: a function that returns the remainder when one number is divided by another number
    • Pseudocode example: x MOD y
    • Python example: x % y
    • Java example: x % y
    • Visual Basic example: x Mod y
  • DIV: a function that returns the quotient when one number is divided by another number
    • Pseudocode example: x DIV y
    • Python example: x // y
    • Java example: x / y
    • Visual Basic example: x \ y
  • ROUND: a function that rounds a number to a specified number of decimal places
    • Pseudocode example: ROUND(x, n)
    • Python example: round(x, n)
    • Java example: Math.round(x * 10^n) / x;
    • Visual Basic example: Math.Round(x, n)
  • RANDOM: a function that generates a random number between x and n
    • Pseudocode example: RANDOM(x,n)
    • Python example: random.randint(x,n)
    • Java example: rand.nextInt(x)
    • Visual Basic example: rand.next(x,n)

Exam Tip

  • Remember to import or include the appropriate library before using the routines in your code

You've read 0 of your 0 free revision notes

Get unlimited access

to absolutely everything:

  • Downloadable PDFs
  • Unlimited Revision Notes
  • Topic Questions
  • Past Papers
  • Model Answers
  • Videos (Maths and Science)

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Becci Peters

Author: Becci Peters

Becci has been a passionate Computing teacher for over 9 years, teaching Computing across the UK helping to engage, interest and develop confidence in the subject at all levels. Working as a Head of Department and then as an educational consultant, Becci has advised schools in England, where her role was to support and coach teachers to improve Computing teaching for all. Becci is also a senior examiner for multiple exam boards covering GCSE & A-level. She has worked as a lecturer at a university, lecturing trainee teachers for Computing.