Choosing a translator for a scenario

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Choosing a translator for a scenario

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A student writes a program in assembly language. Which translator is needed?
A A compiler, because assembly language is a high-level language
B An assembler, because assembly language must be translated into machine code
2. A team is still testing and fixing a Python program. Which translator suits this stage best?
A An interpreter, because it runs the code line by line and stops at an error
B A compiler, because it must create an executable file before every small test
3. A company is ready to sell its finished game to customers. Which translator should be used?
A A compiler, because it produces an executable file that runs without the source code
B An interpreter, because customers need the source code and a translator to run it
4. Which justification is the best answer for choosing an interpreter during development?
A I chose an interpreter because it is the best translator.
B I chose an interpreter because I can test each part of the program and see errors straight away.
5. A programmer writes code using mnemonics such as LDA and ADD. What should they choose?
A Assembler
B Interpreter

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Assembly code -> assembler AAn interpreter needs the source code each time and runs slowly. A compiler should be chosen for release because it gives an executable file.
2Testing a program -> interpreter BInterpreter, because it stops at the error line
3Releasing software to customers: choose a compiler because it makes an executable file that does not need the source code. CAssembly language can only be translated by an assembler, so choose an assembler for it.
4A justified answer names the translator and gives a reason after the word 'because'. DTranslator = compiler (release)
5Assembly code -> use a compiler EA compiler translates high-level code, not assembly language. Assembly code needs an assembler.
6Selling the game to customers -> interpreter FWhile a program is being developed and tested, choose an interpreter because it runs line by line and stops at an error.

Definitions

choose a translator

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF language = "assembly" THEN translator ← "_________" ENDIF
2.
IF stage = "testing" THEN translator ← "___________" ENDIF
3.
IF stage = "release" THEN translator ← "________" ENDIF
4.
stage ← "release" OUTPUT "Compiler _______ it is for release"
5.
IF language = "________" THEN translator ← "assembler" ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A stage ← 'release'
B IF stage = 'release' THEN
C translator ← 'compiler'
D why ← 'runs line by line'
E ENDIF
Question 2
A language ← assembly
B IF language = 'assembly' THEN
C translator ← 'assembler'
D ENDIF
Question 3
A stage ← 'testing'
B IF stage = 'testing' THEN
C translator ← 'compiler'
D ENDIF
Question 4
A stage ← 'release'
B IF stage = 'release'
C translator ← 'compiler'
D ENDIF
Question 5
A stage ← 'testing'
B IF stage = 'testing' THEN
C translator ← 'interpreter'
D why ← 'makes an .exe file'
E ENDIF

Answer Key

Choosing a translator for a scenario
Section A: Quick Questions
Q1
B — An assembler, because assembly language must be translated into machine code
Q2
A — An interpreter, because it runs the code line by line and stops at an error
Q3
A — A compiler, because it produces an executable file that runs without the source code
Q4
B — I chose an interpreter because I can test each part of the program and see errors straight away.
Q5
A — Assembler
Section B: Match the Pairs
Q1
Assembly code -> assembler → Assembly language can only be translated by an assembler, so choose an assembler for it.
Q2
Testing a program -> interpreter → While a program is being developed and tested, choose an interpreter because it runs line by line and stops at an error.
Q3
Releasing software to customers: choose a compiler because it makes an executable file that does not need the source code. → Translator = compiler (release)
Q4
A justified answer names the translator and gives a reason after the word 'because'. → Interpreter, because it stops at the error line
Q5
Assembly code -> use a compiler → A compiler translates high-level code, not assembly language. Assembly code needs an assembler.
Q6
Selling the game to customers -> interpreter → An interpreter needs the source code each time and runs slowly. A compiler should be chosen for release because it gives an executable file.
Section C: Definitions
Q1
choose a translator — Pick an assembler for assembly code, an interpreter while testing a program, or a compiler for release to customers, then justify your choice using 'because'.
Section D: Fill in the Blanks
Q1
IF language = "assembly" THEN translator ← "assembler" ENDIF
Q2
IF stage = "testing" THEN translator ← "interpreter" ENDIF
Q3
IF stage = "release" THEN translator ← "compiler" ENDIF
Q4
stage ← "release" OUTPUT "Compiler because it is for release"
Q5
IF language = "assembly" THEN translator ← "assembler" ENDIF
Section E: Spot the Error
Q1
D — A compiler does not run code line by line. It translates the whole program into an executable (.exe) file, which is why it suits release. That is the reason to give. The line should be why ← 'makes an .exe file'.
Q2
A — The text 'assembly' must be in quotes. Without quotes, assembly is read as a variable name that does not exist. It should be language ← 'assembly'.
Q3
C — While a program is being tested, an interpreter is the better choice because it runs the code line by line and stops at an error. The line should be translator ← 'interpreter'.
Q4
B — An IF statement must end its condition with THEN. The line should be IF stage = 'release' THEN.
Q5
D — Making an .exe file is what a compiler does, not an interpreter. The reason for choosing an interpreter while testing is that it stops at errors. The line should be why ← 'it stops at errors'.