0% found this document useful (0 votes)
4 views

2.5 Programming Languages and IDE + Answers

The document is an examination paper for Computer Science focusing on programming languages and Integrated Development Environments (IDEs). It includes instructions for candidates, questions about high-level and low-level languages, translation methods, and features of IDEs. The paper assesses candidates' understanding of programming concepts, algorithms, and the use of IDE tools.

Uploaded by

xagipo2218
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

2.5 Programming Languages and IDE + Answers

The document is an examination paper for Computer Science focusing on programming languages and Integrated Development Environments (IDEs). It includes instructions for candidates, questions about high-level and low-level languages, translation methods, and features of IDEs. The paper assesses candidates' understanding of programming concepts, algorithms, and the use of IDE tools.

Uploaded by

xagipo2218
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Computer Science (9-1)

2.5 Programming Languages & IDE


Salman Uddin
Please note that you may see slight differences between
this paper and the original.
Duration: Not set
Candidates answer on the Question paper.

OCR supplied materials:


Additional resources may be supplied with this paper.

Other materials required:


• Pencil
• Ruler (cm/mm)

INSTRUCTIONS TO CANDIDATES
• Write your name, centre number and candidate number in the boxes above. Please write clearly and in capital letters.
• Use black ink. HB pencil may be used for graphs and diagrams only.
• Answer all the questions, unless your teacher tells you otherwise.
• Read each question carefully. Make sure you know what you have to do before starting your answer.
• Where space is provided below the question, please write your answer there.
• You may use additional paper, or a specific Answer sheet if one is provided, but you must clearly show your candidate
number, centre number and question number(s).

INFORMATION FOR CANDIDATES


• The quality of written communication is assessed in questions marked with either a pencil or an asterisk. In History and
Geography a Quality of extended response question is marked with an asterisk, while a pencil is used for questions in
which Spelling, punctuation and grammar and the use of specialist terminology is assessed.
• The number of marks is given in brackets [ ] at the end of each question or part question.
• The total number of marks for this paper is 60.
• The total number of marks may take into account some 'either/or' question choices.

© OCR 2022. You may photocopy this page. 1 of 23 Created in ExamBuilder


1 Describe the advantages of writing a program in a high-level language instead of in assembly language.

[2]

2(a) A computer game is written in a high-level programming language.

State why the computer needs to translate the code before it is executed.

[1]

(b) Either a compiler or an interpreter can translate the code.

Describe two differences between how a compiler and an interpreter would translate the code.

[4]

© OCR 2022. You may photocopy this page. 2 of 23 Created in ExamBuilder


3(a)
Tick (✓) one box in each row to identify whether the statement refers to a high-level language or a low-level
language.

Statement High-level language Low-level language


Uses English-like keywords such as
print and while

Must be translated before the processor


can execute code

Code written is portable between different


processors

Requires the programmer to understand


the processor’s registers and structure

[4]
(b) A translator is a common tool found in an Integrated Development Environment (IDE).

Describe two other common tools or facilities that an IDE can provide.

[4]

© OCR 2022. You may photocopy this page. 3 of 23 Created in ExamBuilder


4 The area of a circle is calculated using the formula π × r2 where π is equal to 3.142 and r is the radius.

A program is written to allow a user to enter the radius of a circle as a whole number between 1 and 30, then
calculate and output the area of the circle.

01 radius = 0
02 area = 0.0
03 radius = input("Enter radius")
04 if radius < 1 OR radius > 30 then
05 print("Sorry, that radius is invalid")
06 else
07 area = 3.142 * (radius ^ 2)
08 print (area)
09 endif
An Integrated Development Environment (IDE) is used to write the program.

Identify two features of an IDE that might be used when writing the program.
1

[2]

© OCR 2022. You may photocopy this page. 4 of 23 Created in ExamBuilder


5 An algorithm is written in a high‐level language. The high level code must be translated into machine code before
a computer processor can execute it.

Describe two methods of translating high level code into machine code.

[4]

© OCR 2022. You may photocopy this page. 5 of 23 Created in ExamBuilder


6(a) Victoria is writing a program using a high level language to display the meaning of computer science acronyms
that are entered. The code for her first attempt at this program is shown below.

01 a = input(“Enter an acronym”)
02 if a == “LAN” then
03 print(“Local Area Network”)
04 elseif a == “WAN” then
05 print(“Wide Area Network”)
06 ……………………………………………………………………………………………
07 ……………………………………………………………………………………………
08 endif
(i) Complete the code above to print out an “unknown” message if any other acronym is entered by the user. [2]

(ii) Describe what is meant by a “high level language”.

[2]

© OCR 2022. You may photocopy this page. 6 of 23 Created in ExamBuilder


(b) Victoria creates her program using an Integrated Development Environment (IDE).

Describe two tools or facilities that an IDE commonly provides.

[4]

© OCR 2022. You may photocopy this page. 7 of 23 Created in ExamBuilder


7(a) Joseph is an author and programmer, and he needs to estimate how many pages his new book will have.

Each page has an average of 300 words. Each chapter starts with a chapter title page.
The number of pages is estimated by;

dividing the number of words by 300


ignoring the decimal part of the division
adding the number of chapters to this total.

Joseph uses the algorithm below to estimate the number of pages, but his algorithm does not give the correct
result.

01 INPUT numberOfWords
02 INPUT numberOfChapters
03 CONST wordsPerPage = 300
04 numberOfPages = RoundDown(numberOfWords / wordsPerPage)
05 numberOfPages = numberOfWords + numberOfChapters
06 OUTPUT numberOfPages

Joseph has used a RoundDown function to remove the decimal part of the division, e.g. RoundDown(6.2)
would return 6, RoundDown(7.8) would return 7.

Joseph is using an Integrated Development Environment (IDE) to produce the program.

One tool in an IDE that Joseph uses is a translator.

Describe two additional tools in an IDE that Joseph could use to help him produce his program.

Tool 1 name:

Tool 1 description:

Tool 2 name:

Tool 2 description:

[4]

© OCR 2022. You may photocopy this page. 8 of 23 Created in ExamBuilder


(b) Joseph's IDE allows him to use both a compiler and an interpreter.

Describe how Joseph could make use of a compiler and an interpreter when producing his program.

Compiler:

Interpreter:

[4]

© OCR 2022. You may photocopy this page. 9 of 23 Created in ExamBuilder


8(a) A microwave oven is controlled by a small, specially built CPU.

The table below shows some CPU instructions and what they mean.

CPU instruction Meaning


00001000 00010100 Add 20 to the timer
00001000 00000001 Add 1 to the timer
00000100 00000001 Subtract 1 from the timer

Using examples from the instructions above, state what is meant by:

Part of the instruction which) specifies


the operation to be carried out
(i) an opcode e.g. 00001000 = add to timer /
00000100 = subtract from timer.

[2]
(Part of the instruction which) supplies
the data / address / value needed for
(ii) an operand an operation
e.g. the number to be added /
subtracted from the timer / numerical
example from the table (00010100 or
00000001) [2]

The time displayed on the microwave oven is represented as two 8-bit binary numbers, one for the minutes
and one for the seconds.

For example;
“8:20” is stored as 00001000 00010100
“15:45” is stored as 00001111 00101101
(b) Show how the time 5:30 will be stored.

[2]
(c) 00001000 00010100 can represent either the instruction for “Add 20 to the timer” or the data for the time “8:20”.

Explain how the CPU can determine whether it represents an instruction or data.

[1]

© OCR 2022. You may photocopy this page. 10 of 23 Created in ExamBuilder


9 The area of a circle is calculated using the formula Π × r2, where Π is equal to 3.142 and r is the radius.

Finn has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30,
and output the area of the circle.

Finn uses an IDE (Integrated Development Environment) to write his programs. Identify two features of an IDE
that Finn might use.

[2]

10(a) Harry is planning to create a computer game using a high-level programming language.

State why the computer needs to translate the code before it is executed.

[1]

© OCR 2022. You may photocopy this page. 11 of 23 Created in ExamBuilder


(b) Harry can use either a compiler or an interpreter to translate the code.

Describe two differences between how a compiler and an interpreter would translate Harry's computer game.

[4]
11 Jim is writing a program to calculate the wages of workers in a teddy bear factory.

Jim uses an Integrated Development Environment (IDE) to create the program.

Describe two tools in an IDE that can help Jim when creating the program.

[4]

© OCR 2022. You may photocopy this page. 12 of 23 Created in ExamBuilder


12 Graeme is a freelance programmer. He has written a program for a client and gives the client both the high level
code and the machine code of the program.

(i) Describe what is meant by

High level code

Machine code

(ii) State why Graeme needs a compiler.

[1]

END OF QUESTION PAPER

© OCR 2022. You may photocopy this page. 13 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

1 1 mark per bullet to max 2 2 Accept “human language” as English for


BP4
Easier/quicker for humans to write AO1
Easier/quicker to read / understand / 1b(2) “Easier to use” is too vague.
remember
Easier/quicker to maintain / debug / Examiner’s Comments
spot errors Question (b) was answered extremely well.
…because code is closer to English / Many candidates were able to articulate
uses English words the advantages of high-level languages
Less code to write over assembly language. Even more
…because one HLL instruction pleasing were the many candidates able to
represents many assembly instructions discuss issues such as portability of code
Portable (between processors) // will and that a high-level instruction translates
work with different types of compute into many assembly instructions.

Total 2

2 a To convert it to binary/machine code 1 Maximum 1 mark


The processor can only understand (AO1 1a)
machine code

b Compiler translates all the code in one 4 1 mark to be awarded for the correct
go… (AO1 1b) identification and one for a valid description
…whereas an interpreter translates up to a maximum of 4 marks.
one line at a time No more than 2 marks for answers relating
Compiler creates an executable… only to interpreters and no more than 2
…whereas an interpreter does marks for answers only relating to
not/executes one line at a time compilers.
Compiler reports errors at the end…
…whereas an interpreter stops when it
finds an error

Total 5

© OCR 2022. You may photocopy this page. 14 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

3 a One mark per row 4 Accept other markings that indicate a


choice has been made (e.g. a cross, etc)

Statement High-level Low-level


language language
Uses English- ✔
like keywords
such as print
and while
Must be ✔
translated
before the
processor can
execute code
Code written is ✔
portable
between
different
processors
Requires the ✔
programmer to
understand the
processor’s
registers and
structure

b 1 mark per bullet, max 4 4 Allow other tools available in an IDE with
suitable expansion (e.g. breakpoints, watch
e.g. window, stepping, pretty printing, etc)

Editor
…to enable program code to be
entered / edited
Error diagnostics / debugger
…to display information about errors /
location of errors / suggest solutions
Run-time environment
…to enable program to be run / to
check for runtime errors / test the
program

Total 8

© OCR 2022. You may photocopy this page. 15 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

4 Error diagnostics (any example) 2 1 mark per bullet to a maximum of 2


Run-time environment (AO1 1a) marks.
Editor (any feature such as auto- Only 1 example per bullet, e.g. auto-correct
correct, auto-indent) and auto-indent would only gain 1 mark.
Translator
Version control
Break point
Stepping

Total 2

5 1 mark per bullet to max 4, 2 mark max per 4 Mark first method only in each section
method AO1 1b
(4) Examiner’s Comments
Compiler
…translates code in one go / all at This question was answered well by large
once numbers of candidates who were able to
…produces an executable file // does list the two translators listed in the
not need to be compiled again specification, compilers and interpreters.

Interpreter Most candidates were then further able to


…translates code line by line. describe the methods used by these
…will be interpreted / translated every translators, such as interpreters translating
time it is run. code line-by-line.

It is pleasing to see that this section of the


specification is obviously well understood
and generally answered with confidence.

Total 4

© OCR 2022. You may photocopy this page. 16 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

6 a 1 mark per bullet, max 2. 2 Accept logically correct equivalents for else
(e.g. elseif a!=“LAN“ and/or a
!=“WAN“). Do not allow elseif on its
else own
print (“unknown”)
Accept other keywords for print (e.g.
“output”) as long as the intention is clear.

Accept other messages as equivalent to


“uknown” (e.g. “not known” / “error”))

Message to be printed must be in quotes.

Allow “else then”.

Examiner’s Comments

Most candidates were able to complete line


07 successfully, with an output/print of an
acceptable ‘unknown’’ message being all
that was required. Line 06 required
candidates to understand that the message
on line 07 should be printed out where the
conditions in lines 02 and 04 were both
false; the simplest way of achieving this
was an ELSE (or equivalent). Where
candidates put more logically complex
statements, these were successful if they
were logically correct. However, many
candidates struggled with this.

Misconception
To compare the contents of a variable
against two possible values, it is incorrect
to use :
• if a!=‘WAN’ or ‘LAN’
In the example above, the comparison of a
against ‘WAN’ is logically correct, but it is
unclear what ‘LAN’ is being compared
against.
A logically correct way to achieve the same
thing would be :
• if a!=‘WAN’ and a!=‘LAN’

© OCR 2022. You may photocopy this page. 17 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

1 mark per bullet, max 2. 2 Allow examples of keywords (eg IF / ELSE


/ WHILE) as 2nd bullet point.

aimed at humans//understandable by
humans / programmers Do not award marks for naming languages
English like structure / syntax such as Java , Python, etc.
Must be
translated/compiled/interpreted (before
it can be run) Do not award marks for stating what a high
Allows programmer to deal with the level language isn’t (i.e. describing what
problem instead of considering the low level code is).
underlying hardware // an abstraction
from the hardware // hardware Do not allow “easy to use”
independent // portable
Do not allow ‘has to be converted’ without
into what i.e machine code etc.

Examiner’s Comments

This question was answered well by many


candidates, with responses relating to the
use of English-like keywords but needing
to be translated before the processor could
execute it being the most popular. A
minority of candidates confused ‘high-level’
with ‘difficult’ and gave incorrect answers
regarding it being too hard to programmers
to use. The opposite is in fact true, with
‘high-level’ referring to the level of
abstraction away from the underlying
hardware.

Very few answers were seen that in any


way discussed this abstraction or
portability between different processors.
Hopefully centres will become more
confident with the delivery of the subject
and so more complex and technically
complete answers will be seen across all
questions from high ability candidates.

© OCR 2022. You may photocopy this page. 18 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

b 1 mark per bullet, max 4. 4 One mark for identifying, one mark for
describing. Accept description of a tool
e.g. without (or with incorrect) naming of the
tool.

Editor
…to enable program code to be Allow sensible descriptions which go
entered/edited across pairs or name other tools sensibly
(e.g. editor / highlighting syntax)
Error diagnostics / debugging
…to display information about errors Allow any sensible tool that an IDE
(syntax / run-time) / location of errors provides (e.g. auto documentation, help
… suggest solutions tools, pretty printing etc.)

Run-time environment
…to enable to the program to be run
… check for run time errors / test the
program

Translator / compiler / interpreter


…to convert the high level code into Examiner’s Comments
machine code / low level code / binary
…to enable to code to be executed / Most candidates were able to gain at least
run some marks from this question, with a
Breakpoints significant number able to access all 4
…to stop/pause program execution at marks. A list of common tools and facilities
a specific point available in an IDE is given in the
specification (section 2.5 ‘Translators and
Watch window facilities of languages’) although other
…to check contents of variables sensible tools that candidates may have
had experience with were also accepted.
Stepping Although many candidates were able to
…to execute program line by line name the tools, they often struggled to
describe these and give more
Syntax completion… comprehensive answers. Again, extensive
…suggests/corrects code practical use of a high-level language
programming language alongside an IDE
Keyword highlighting / colour coding would have been extremely beneficial to
keywords / pretty printing… candidates and centres.
…colours command words / variables

Total 8

© OCR 2022. You may photocopy this page. 19 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

7 a 1 mark for identification, 1 for matching 4 Do not allow auto-documentation.


description e.g. Can get description mark, without
identification / incorrect identification
Error diagnostics / debugger
… highlight errors / suggest changes Allow:

Run-time environment Variable watch / window


… Lets you run / test the program See how the values change

Text editor Do not allow compiler / interpreter


…highlight key words
…auto-indent Examiner's Comments
…to type / edit source code
…Auto-complete This question was appropriate
…highlight syntax errors programming theory and techniques.

Versioning tools This question was not answered well.


…To allow for tracing back Many candidates did not know what an IDE
…To create new files with changes was, often giving utility programs as
responses. A significant number of
Stepping / breakpoints candidates gave compiler and interpreter
…Allow tracing of algorithms as answers, showing that they did not
understand that these are examples of the
translator that was given in the question.
The better candidates were able to name
the tools, as given in the specification, and
describe them. Marks were often given for
descriptions of the tools, where they could
not be named.

© OCR 2022. You may photocopy this page. 20 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

b Max 2 for compiler, 2 for interpreter 4 The uses must be different for compiler
Compiler and interpreter

To convert to low-level in one go Examiner's Comments


Create an executable // export the file
To distribute the software This question was appropriate
Users will have no access to source programming theory and techniques.
code…
…so no-one can edit / steal / copy the Many candidates did not answer the
code / program question, instead giving definitions of
Use for error detection compilers and interpreters, instead of
describing how they were used when
Interpreter producing a program. The most common
answers involved checking for errors.
To convert to low-level line by line
To test the program // to find errors
stops running when it finds an error //
shows the location of the error when
found
it is quicker (compared to compiler) to
re-interpret than recompile

Total 8

8 a i (Part of the instruction which) specifies 2 The answer must refer specifically to the
the operation to be carried out operation to be carried out and not the
e.g. 00001000 = add to timer / instruction as a whole.
00000100 = subtract from timer

ii (Part of the instruction which) supplies 2 For data, accept number / integer.
the data / address / value needed for
an operation
e.g. the number to be added /
subtracted from the timer / numerical
example from the table (00010100 or
00000001)

b 00000101 00011110 2 All 8 bits must be correct for each byte.


1 mark per byte

c Instructions and data are fetched at 1 Award the mark for:


different points of the fetch execute
cycle
Instructions and data are kept in The program counter points to the
separate parts of the memory (by the address of instructions
operating system)

Total 7

© OCR 2022. You may photocopy this page. 21 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

9 Error diagnostics (any example) 2 1 mark per bullet to a maximum of 2


Run-time environment marks. Only 1 example per bullet, e.g. auto-
Editor (any feature such as auto- correct and auto-indent would only gain 1
correct, auto-indent) mark.
Translator
Version control
Break point
Stepping

Total 2

10 a To convert it to binary / machine code 1 Maximum 1 mark


The processor can only understand
machine code

b Compiler translates all the code in one 4 1 mark to be awarded for the correct
go… identification and one for a valid description
… whereas an interpreter translates up to a maximum of 4 marks. No more
one line at a time than 2 marks for answers relating only to
Compiler creates an executable… interpreters and no more than 2 marks for
…whereas an interpreter does not / answers only relating to compilers.
executes one line at a time
Compiler reports all errors at the end…
… whereas an interpreter stops when it
finds an error

Total 5

11 e.g. 4 Do not accept me spell check

Examiner's Comments

Editor It was pleasing to see that candidates were


Allows Jim to enter the program code using their experience of programming to
Colour coding keywords answer the question. Where they did not
Auto-completes code as you type. gain full marks, this could have improved
Compiler by providing further detail about the tools,
Transforms the written source code or especially by using correct technical
into machine code. terms to describe these tools.
Debugging tools
Highlights errors in the code
Suggests possible solutions.

(2 marks per tool)

Total 4

© OCR 2022. You may photocopy this page. 22 of 23 Created in ExamBuilder


Mark Scheme

Question Answer/Indicative content Marks Guidance

12 i High level code : 4 Award marks for correct points about


machine code made under high level code
and vice versa.
human oriented code / written by
programmers Do not accept Machine code is in Hex
contains words for commands / closer
to English / natural language
Machine independent / Portable to
different systems
Needs to be translated before it can be
executed.
Problem based
One (high level) command equates to
many machine code instructions.

Machine code:

Code for the CPU to execute / not


readily understandable by humans
binary instructions
specific to a particular (type of)
computer / not portable to different
systems
does not need to be translated

[max 2 marks for each type of code]

ii To translate the high level code into 1 Translate to object code is acceptable
machine code Accept “errors” on its own, but do not
To pick up (syntax) errors accept answers referring specifically to
logic or runtime errors.

Total 5

© OCR 2022. You may photocopy this page. 23 of 23 Created in ExamBuilder

Powered by TCPDF (www.tcpdf.org)

You might also like