Library routines
About this lesson: Library routines
In short
Languages include tested routines you can use straight away. Try each.

What you'll explore
- Ready-made routines: ROUND, RANDOM, MOD, DIV
- Languages include tested routines you can use straight away. Try each.
- Random numbers: Roll the dice
- Random numbers make games unpredictable. Roll once, then 100 times.
- String functions: Length and case
- LENGTH, UCASE and LCASE are library routines too.
- Why use libraries?: Don't reinvent the wheel
- Library code is tested, fast and saves time. Compare writing your own with using a library.
- Check yourself: MOD
- What is 23 MOD 4?
Also in this lesson
- Step by step
- Watch out for these
- More than the lesson
- Stretch your brain
- Try it yourself
Words to know
- Library routine
- A pre-written subroutine supplied with a language.
- MOD
- Remainder after division.
- DIV
- Whole-number division.
- Random number
- An unpredictable value.
- Import
- Load a library into a program.
Sources
- Python documentation: random module
- Python documentation: built-in functions
- Raspberry Pi Foundation, Isaac Computer Science: library routines
- BBC Bitesize, GCSE Computer Science: subroutines
← Parameters, local and global variables · Two-dimensional arrays →