← International GCSE Computer Science · Edexcel · GCSE Computer Science revision
⭐ 0
Pearson Edexcel International GCSE Computer Science (4CP0) · 4.3–4.5 Logic, software and programming languages
Mini-Lesson

Logic, software and programming languages

6 missions. Guess, learn, then check. Your place is saved.

  1. Mission 1"Tea or coffee?" Would a computer's OR let you have both?
  2. Mission 2Three sensors, one alarm: how many cases must you test?
  3. Mission 3One CPU core, three apps at once. How is that possible?
  4. Mission 4Why could shuffling files around make an old hard drive faster?
  5. Mission 5Why write a 1999 hit game almost entirely in assembly?
  6. Mission 6Why do some languages show all your errors, and others just one?
Mission 1

"Tea or coffee?" Would a computer's OR let you have both?

Make a guess: "Tea or coffee?" Would a computer's OR let you have both?

Boolean logic · AND, OR, NOT

1 or 0, and NOT

NOTANOT A0110
  • A Boolean value has only two states: 1 (TRUE) or 0 (FALSE).
  • A truth table lists every possible combination of inputs with the output for each.
  • NOT has one input and reverses it: NOT 0 = 1, NOT 1 = 0.
  • Write it as NOT A.
Boolean logic · AND, OR, NOT

AND

Truth tablesABA AND B000010100111ANDABA OR B000011101111OR
  • AND has two inputs. The output is 1 only when both inputs are 1.
  • If either input is 0, the output is 0.
  • Write it as A AND B.
ABA AND B
000
010
100
111
Boolean logic · AND, OR, NOT

OR

Truth tablesABA AND B000010100111ANDABA OR B000011101111OR
  • OR has two inputs. The output is 1 when at least one input is 1.
  • The output is 0 only when both inputs are 0.
  • This is wider than everyday "or", which often means "one or the other, not both".
  • Write it as A OR B.
ABA OR B
000
011
101
111
Your answer
?A = 1 and B = 0. Work out NOT A, then A AND B, then A OR B. Type the three output bits in that order.
Quick check
?A cash machine gives out money only if the card is valid (V) and the PIN is correct (P). Which logic statement matches?
Mission check

?"Tea or coffee?" A customer ticks both, so Tea = 1 and Coffee = 1. What does Tea OR Coffee give?
Mission 2

Three sensors, one alarm: how many cases must you test?

Make a guess: Three sensors, one alarm: how many cases must you test?

Boolean logic · combining operators

Combining operators

  • One logic statement (expression) can use several operators, e.g. (A AND B) OR NOT C.
  • Work out brackets first.
  • NOT applies only to the input or bracket just after it.
  • Example: (1 AND 0) OR (1 AND 1) = 0 OR 1 = 1
Boolean logic · combining operators

Every combination of three inputs

Counting the rows1 inputA012 rows×22 inputsAB000110114 rows×23 inputsABC0000010100111001011101118 rows
  • Each input can be 0 or 1, so each new input doubles the number of rows.
  • 1 input: 2 rows. 2 inputs: 4 rows. 3 inputs: 8 rows.
  • Fill the input columns by counting up in binary from 000 to 111. Then no row is missed or repeated.
Boolean logic · combining operators

Working columns

Working columnsABCA AND BNOT CP000011001000010011011000100011101000110111111101
  • For a long statement, add a column for each part.
  • Example: P = (A AND B) OR NOT C.
  • Column 4: A AND B. Column 5: NOT C. Column 6: P = column 4 OR column 5.
  • Working columns are optional, but they stop you mixing up steps.
ABCA AND BNOT CP
000011
001000
010011
011000
100011
101000
110111
111101
Your answer
?Q = (A OR B) AND NOT C. Complete the output column for the rows 000, 001, 010, 011, 100, 101, 110, 111 (in that order). Type the 8 bits.
Boolean logic · combining operators

From a problem to a logic statement

  • Give each condition a letter (1 = true, 0 = false).
  • "and" → AND; "or" / "either" → OR; "not" / "is off" → NOT.
  • Use brackets to group conditions that go together.
  • Example: the alarm X sounds if the door is open (D) and the system is armed (S), or if the panic button (P) is pressed.
  • X = (D AND S) OR P
Quick check
?A greenhouse sprinkler W switches on when the soil is dry (D) and it is not raining (R), or when the manual override (M) is pressed. Which logic statement matches?
Mission check

?Three sensors, one alarm. How many different input combinations must the truth table cover?
Mission 3

One CPU core, three apps at once. How is that possible?

Make a guess: One CPU core, three apps at once. How is that possible?

Systems software · operating systems

The manager between apps and hardware

LayersUserrequestsresultsApplication softwarerequestsresultsOperating systemrequestsresultsHardware
  • The operating system (OS) is system software that manages the hardware and provides a platform for applications to run on.
  • Apps don't control the hardware themselves: they ask the OS.
  • The OS loads apps into memory, starts them and closes them.
  • System software manages the computer's resources, e.g. the OS and utility software. Application software does tasks for the user, e.g. a web browser or a game.
Systems software · operating systems

Sharing the processor and memory

Time slicesCPU coreMDEMDEMDEOS switches at each dividing lineWhat you see: all three runningMusicDownloadEssay
  • Each running program is a process. One core runs one instruction at a time.
  • The OS schedules processes: each gets a short time slice on the CPU, then the OS switches to the next.
  • Switching is so fast that programs seem to run at once: multitasking.
Quick check
?On a single-core laptop you play music, download a file and type an essay. What keeps all three going?
Systems software · operating systems

Devices and files

PrintingWord processorOperating systemPrinter drivertranslates OScommands for thisprinter modelPrinter
  • The OS manages peripherals (input, output and storage devices) and the data passing between them and the processor.
  • A device driver lets the OS communicate with one particular device. It translates OS commands into ones that device understands.
  • File management: the OS organises files into folders and lets you name, save, move, copy and delete them.
Systems software · operating systems

Interface, users and security

  • The user interface lets you control the computer, e.g. a graphical user interface (GUI) with windows, icons, menus and a pointer, or a command-line interface where you type commands.
Quick check
?A new printer is detected, but every page comes out as strange symbols. Which software most likely needs installing or updating?
Mission check

?One CPU core, three apps at once. How is that possible?
Mission 4

Why could shuffling files around make an old hard drive faster?

Make a guess: Why could shuffling files around make an old hard drive faster?

Systems software · utility software

Housekeeping software

  • Utility software is system software that helps to maintain, protect or configure a computer.
  • It carries out housekeeping tasks that the operating system may not do, or may not do well enough, on its own.
  • Some utilities come with the OS; others are installed separately.
  • Examples: file managing, repairing and converting tools, compression, defragmentation, backup and anti-malware software.
Systems software · utility software

Fragmented files

Defragmentationmagnetic hard diskBeforeread/write head jumpsA1A2B3456A78B9B1011A121314B1516AfterA1A2A3A4B5B6B7B8910111213141516File AFile Bfree
  • A magnetic hard disk stores files in blocks. The read/write head moves to each block to read it.
  • As files are saved and deleted, free space becomes scattered gaps, so new files get split up: they are fragmented.
  • Reading a fragmented file needs many slow head movements.
  • A disk defragmenter moves each file's pieces next to each other (contiguous) and groups the free space together, so files load faster.
Quick check
?Ali's new laptop has a solid state drive (SSD). Is it worth running a defragmenter on it?
Systems software · utility software

Backup, compression and encryption

Utility softwareBackuporiginal stayscopyexternal drivecloudCompressionfewer bytesEncryptionMeet at 3q#8Vz!2Lm
  • Backup software copies files to another device or the cloud, so they can be restored if lost or damaged.
  • Compression software makes files smaller, so they use less storage space and transfer faster.
Systems software · utility software

Protecting and repairing files

  • Anti-malware (antivirus and anti-spyware) software scans files and memory for malware, comparing them with known malware signatures and watching for suspicious behaviour. It quarantines or deletes what it finds.
  • File repair tools fix damaged or corrupted files so they can be opened again.
  • Other utilities manage files (copy, rename, organise) and convert files from one format to another.
Quick check
?Mia's folder of reports and spreadsheets is 45 MB, but her email allows attachments up to 20 MB. Which utility helps most?
Mission check

?Why could shuffling files around make an old hard drive faster?
Mission 5

Why write a 1999 hit game almost entirely in assembly?

Make a guess: Why write a 1999 hit game almost entirely in assembly?

Languages · levels of programming language

What the processor actually runs

Machine codeopcodeoperand000101000011010100100110CPUillustrative 8-bit instruction set(not a real processor)
  • A CPU can only execute machine code: instructions in binary.
  • Each instruction is a simple step, such as load a value, add, store a result or jump.
  • Each processor family has its own instruction set, so machine code for one family won't run on another.
  • Machine code and assembly language are low-level languages: they work directly with the processor's own instructions.
Languages · levels of programming language

Assembly language

Assembly to machine codeAssemblyMachine codeLDA price00010100ADD tax00110101STA total00100110assembler
  • Assembly language replaces binary with short mnemonics such as LDA (load), ADD and STA (store).
  • Each assembly instruction matches exactly one machine code instruction: a 1:1 correspondence.
  • Like machine code, it is specific to one processor family.
  • An assembler translates assembly language into machine code.
Assembly language (illustrative)
LDA price    ; load price into the processor
ADD tax      ; add tax to it
STA total    ; store the result in total
Languages · levels of programming language

High-level languages

  • High-level languages use English-like keywords and maths-style expressions.
  • One statement often becomes several machine code instructions: the line below becomes the three assembly instructions you just met.
  • They are machine independent: the same source code can be translated to run on different processor families.
  • A compiler or interpreter must translate the code before the CPU can run it.
  • Most programs are high-level: they are quicker to write, read and debug.
Pearson pseudocode
SET total TO price + tax
Quick check
?A programmer writes the line STA total. What kind of code is this?
Calculate
?An assembly program has these 3 lines: LDA price, ADD tax, STA total. How many machine code instructions will it become?
Languages · levels of programming language

Choosing a level

Levels of languageeasier for humanscloser to the hardwareHigh-leveltotal = price + taxAssemblyLDA price ADD tax STA totalMachine code0001 0100 0011 01010010 0110low-level
High-levelLow-level
Reading and writingeasier: English-likeharder: mnemonics or binary
Debuggingeasier to find and fix errorsharder
Portabilitymachine independentworks on one processor family
Hardware controlindirect, through the OSdirect control of registers and memory
Speed and memorytranslated code may be less efficientcan be very fast and compact
  • Use low-level for device drivers, embedded systems and code where speed or memory is critical.
  • Use high-level for most applications, where quick development matters more.
Quick check
?A smart thermostat has a tiny chip with very little memory, and its program must control a temperature sensor directly. Which level of language suits it best?
Mission check

?Why write a 1999 hit game almost entirely in assembly?
Mission 6

Why do some languages show all your errors, and others just one?

Make a guess: Why do some languages show all your errors, and others just one?

Languages · translators

Why translate?

TranslatorsSource codeTranslator0110 10111001 0010Machine codeCPUHigh-levelCompilerHigh-levelInterpreterAssemblyAssembler
  • The CPU can only execute machine code, so the source code that programmers write must be translated first.
  • A translator is a program that converts source code into a form the CPU can execute.
  • High-level code is translated by a compiler or an interpreter.
  • Assembly is translated by an assembler: each assembly instruction becomes one machine code instruction.
Languages · translators

Compiler or interpreter?

Compiler and interpreterCompiler8 linestranslateEXEexecutablerunInterpreterline 1translaterunline 2translaterunline 3translaterun… and so on, one line at a time, to line 8
  • A compiler translates the whole program before it runs, producing an executable file of machine code that runs without the compiler.
  • An interpreter translates and runs the code one line at a time. It is needed every time the program runs.
  • Errors: a compiler gives an error report for the whole program; an interpreter stops at the first error.
Quick check
?An 8-line program has errors on lines 4 and 7. What happens when you run it with an interpreter?
Languages · translators

Choosing a translator

When each is usedInterpreterwhile developingeditrunfixCompilerfor releasereleaseEXEusers
CompilerInterpreter
Translatesthe whole program, before it runsone line at a time, as it runs
Producesan executable fileno executable file
Running speedfast: already translatedslower: translated again every run
Finding errorsreport after translating everythingstops at the error, easy to see where
After a changemust recompile the whole programjust run it again
Sharingsend the executable; source stays privateusers need the source and an interpreter
  • An interpreter is mostly used while developing and testing a program; a compiler translates the final program for release.
  • An assembler is used when a program is written in assembly, e.g. for embedded systems or device drivers.
Quick check
?A games studio is ready to release its finished game and doesn't want players to see its source code. Which translator should it use?
Mission check

?Why do some languages show all your errors, and others just one?
Recap

Big ideas

  • Every input and output is 1 (TRUE) or 0 (FALSE). A truth table lists every combination of inputs.
  • AND: 1 only if both inputs are 1. OR: 1 if at least one input is 1. NOT: reverses its one input.
  • Work out brackets first; NOT applies only to what comes straight after it.
  • 3 inputs give 8 rows: count in binary from 000 to 111, and add working columns for each part.
  • Turn a problem into a statement by giving each condition a letter and mapping "and", "or", "not".
  • The OS is system software that manages the hardware and gives applications a platform to run on.
  • It shares the processor between processes (multitasking) by scheduling short time slices, and manages peripherals using device drivers.
  • It also manages files and the user interface.
  • Utility software is system software that does housekeeping tasks to maintain, protect or configure the computer.
  • A defragmenter makes files contiguous on a magnetic hard disk so they load faster; it isn't needed on an SSD.
  • Backup, compression, file repair and anti-malware tools each protect, shrink or fix your files.
  • The CPU only runs machine code (binary); assembly uses mnemonics with a 1:1 match to machine code. Both are low-level and tied to one processor family.
  • High-level languages are easier to write, read and debug and are machine independent, but must be translated.
  • Low-level suits device drivers, embedded systems and speed-critical code; high-level suits most applications.
  • Source code must be translated before the CPU can run it: a compiler translates the whole program into an executable; an interpreter translates and runs it line by line.
  • Interpreters suit development and testing; compilers suit the final program; assemblers translate assembly language.
🏆

Mini-lesson complete!

⭐⭐⭐

You've worked through Logic, software and programming languages for Pearson Edexcel International GCSE Computer Science (4CP0). 🎉

  1. Mission 1"Tea or coffee?" Would a computer's OR let you have both?
  2. Mission 2Three sensors, one alarm: how many cases must you test?
  3. Mission 3One CPU core, three apps at once. How is that possible?
  4. Mission 4Why could shuffling files around make an old hard drive faster?
  5. Mission 5Why write a 1999 hit game almost entirely in assembly?
  6. Mission 6Why do some languages show all your errors, and others just one?

Your stars: 0 / 0

Next: more International GCSE Computer Science · Edexcel lessons and games on the International GCSE Computer Science · Edexcel page.

📣 Smashed it? Share your score

Challenge a mate to beat your stars, or show a parent how you got on.

→ Back to International GCSE Computer Science · Edexcel

Specification points and sources for this lesson are listed at the bottom of the page.

Sources (9)

The specification points and sources behind this lesson.

  1. 1 Pearson Edexcel International GCSE 4CP0 spec, 4.3.1
  2. 2 Pearson Edexcel International GCSE 4CP0 spec, 4.3.1–4.3.2
  3. 3 Edexcel IGCSE 4CP0 spec, 4.4.1, 4.4.4
  4. 4 Edexcel IGCSE 4CP0 spec, 4.4.2
  5. 5 Edexcel IGCSE 4CP0 spec, 4.5.1
  6. 6 Edexcel IGCSE 4CP0 spec, 4.5.2
  7. 7 Chris Sawyer (the game's creator), official site: FAQ "Chris Sawyer Software Development", Q "What language was RollerCoaster Tycoon programmed in?" ("99% written in x86 assembler/machine code … with a small amount of C code used to interface to MS Windows and DirectX"), https://chrissawyergames.com/faq3.htm; release "early in 1999": https://chrissawyergames.com/info.htm
  8. 8 Atari (publisher of the RollerCoaster Tycoon series), "Interview with RollerCoaster Tycoon's creator Chris Sawyer", Atari's own Medium publication Atari Club, Carly Francis, 27 March 2024; Sawyer's own answer to "Why did you write RollerCoaster Tycoon in assembly language … rather than a high level language like C?", https://medium.com/atari-club/interview-with-rollercoaster-tycoons-creator-chris-sawyer-684a0efb0f13
  9. 9 PCGamesN, "RollerCoaster Tycoon: the best-optimised game of all time?", https://www.pcgamesn.com/rollercoaster-tycoon/code-chris-sawyer