System: You are ChatGPT, a large language model trained by OpenAI.
User: I will send you a body of text, I will then state what you do next.
User: 224Subroutines, local and global variables LEARNING OBJECTIVESIn this chapter you will learn: •what a subroutine is and how they are used to create programs •how to create subroutines•what a function is and how to create them •what parameters and arguments are and how they are used withina func tion•what local and global variables are. A-level students will learn: •what an exception is and how a program should deal with it. INTRODUCTIONIn programming a subroutine  is a named block of programming code  that performs a speciﬁ  c task. All programs therefore are made up of a series of subroutines. They provide structure to programs in the same way that chapters provide structure to a book. Subroutines are also called procedures , subprograms  or routines . Subro utines use variables that can either be local or global. Local variab les are those that can only be used within that subroutine whereas global variables  are accessible throughout the program.SPECIFICATION COVERAGE 3.1.1.9 Exception handling 3.1.1.10 Subroutines (procedures/functions)3.1.1.11 Parameters of subroutines3.1.1.12 Returning a value/values from a subroutine3.1.1.13 Local variables in subroutines3.1.1.14 Global variables in a programming languageKEYWORDS Subroutine: a named block of code designed to carry out a specific task. Procedure: another term for a subroutine.Su bprogram: another term for a subroutine.Ro utine: another term for a subroutine. Local variable: a variable that is availa ble only in specified subroutines and functions.Global variable: a variable that is availa ble anywhere in the program.SUBROUTINES 23●SubroutinesA subroutine is self-contained and it carries out one or more related processes. These processes are sometimes called algorithms, which in turnare made up of lines of code. Subroutines must be given unique identifiersor names, which means that once they have been written they can be calledusing their name at any time while the program is being run.
 For example you may want to write a program to maintain the contents ofa file. You would need to write code to handle tasks such as adding a newrecord, amending existing details and deleting an old record. In this caseyou might have a subroutine to handle events  that are generated froma mai n men u and then each of the three tasks has its own subroutine.
 For example if the variable Selected  is set to Add then the procedure AddRecord  would be called.
 Subroutine MainMenuInput SelectedIf Selected = "Add" Then Subroutine AddRecordIf Selected = "Amend" Then Subroutine AmendRecordIf Selected = "Delete" Then Subroutine DeleteRecord End Subroutine: Subroutine AddRecord‘Code to add a new record to a fileEnd Subroutine: Subroutine AmendRecord‘Code to locate and amend an existing recordEnd Subroutine: Subroutine DeleteRecord‘Code to delete an existing recordEnd SubroutineBreaking up a program into manageable blocks like this has many benefits: ●They can be called at any time using the subroutine’s unique name.
 ●They allow you to gain an overview about how the program is putogether. ●You can use a top-down approach to develop the whole project. ●The program is easier to test and debug because each subroutine is self-conta ined.
 ●Very large projects can be developed by more than one programmer.Vis ual Basic forces you to work with subroutines. In Visual Basic as soon as you try to write code that is connected to a control, Visual Basic creates a subroutine for you. Object-oriented programming takes this concept KEYWORDEvent: something that happens when a program is being run. 4 Subroutines, local and global variables 24one stage further by putting all the code and the relevant data in the same module  and the modules are put together to form the overall program. In this context a module is one part of a program that may contain several  subroutines. See Chapter 6 for more details. ●Functions Functions  are similar to subroutines but return a value. For example, mostmodern pocket calculators have a large range of functions. The most basic are probably the square and square root keys. The idea is that you entera number, press the function key you want and the calculator gives you aresult based on that number.A function in a computer program performs much the same task as the buttons on a calculator. The user supplies the function with data and thefunction returns a value. For example you could create a function thatcalculates the volume of a cylinder – you supply the height and radius andthe function returns the volume. This process is not limited to numeric data; for example, you could createa function to count the number of times the letter ‘h’ occurs in a givenblock of text, or to check to see if a file has read/write or read-only accessrestrictions in place.
 There are two benefits of using functions in a program: ●Some processes are very complex and involve many lines of code, but in thend they p roduce a single result. Including all those lines of complex codein the middle of your program will probably make it harder to understand,so instead you could put the code in a function and put the function itselfsomewhere else in the program, away from the main body of the program.This also means that if you want to alter the function it is easier to find. Italso makes the main body of the code easier to work through. ●If you have to carry out the same process in lots of different places in the program, then instead of having to rewrite the same code over and over again, you would create the code once as a function and call it fromthe various places through the program. This has the benefit of keepingprograms smaller, and if you need to alter the way the function works,you only have to alter one version of it.
 Functional programming  is a method of programming that only uses funct ions. There is more on this in Chapters 46 and 47.
 ●Parameters and argumentsIn order for a subroutine or function to operate efficiently you need a way tocontrol the data that it takes in. This is usually done by using parameters and arg uments. A parameter works like a variable in that it identifies the data that you want a subroutine to take in and use. The argument  is theactual va lue being passed to the subroutine.
 The way that this is implemented varies depending on the programminglanguage being used. As the subroutine being called is external to thecurrent subroutine, there needs to be a mechanism for ensuring that theprogram knows how to handle the subroutine that has been called. It doesthis using a block interface , which is essentially a block of code thatspecif ies the type and characteristics of the data being passed.KEYWORDModule: a number of subroutines that form part of a program.
 KEYWORD Function: a subroutine that returns a v alue.
 KEYWORDFunctional programming: a programming paradigm that uses functions to create programs. KEYWORDSParameter: data being passed into a subroutine. Argument: an item of data being passed to a subroutine. Block interface: code that describes the data being passed from one subroutine to another.Figure 4.1 Function keys on a calculatorLOCAL AND GLOBAL VARIABLES 25●Local and global variablesAs we have seen, it is highly likely that your program will be split up into lots of subroutines and functions. If you do this then you have to decide onthe scope of any variables created. This means you have to construct yourprogram in a way that either: ●limits the existence of the variable to the subroutine or function in whichit was declared – a local variable, or ●allows the variable to be used anywhere in the program – a global variable. The value of a variable is constantly changing throughout the program and as you have seen, values may be passed around between subroutines. If the subroutine changes the value stored in the variable, this may be passed back to the original subroutine or on to another subroutine. An important aspect of programming is keeping track of the state of variables and one of the main causes of program errors is when the value of a variable is changed within one subroutine, that then has an impact on another subroutine. This is known as a side effect.It is good practice to use local variables wherever possible and using them  has a number of advantages: ●You cannot inadvertently change the value being stored somewhere elsein the program. ●You could use the same variable name in different sections, and each could be treated as a separate variable.
 ●You free up memory as each time a local variable is finished with, it is removed from memory. You should only use a global variable where it needs to be available throughout the whole program. For example, you might store the password to a program as a global variable if you wanted to make a password accessible to different sections of your code.
 When programming, different syntax is required to indicate whether the variable is local or global. For example in Visual Basic: ●Local variables are declared using the Dim  statement: Dim Age As Integer  declares a local variable called Age. ●Global variables are described as public: Pub lic Password As Text  declares a global variable calledPassword .In Python all variables are assumed to be local when they are defined. If you want a variable to be global you must tell Python to make it global by using the global  keyword, which actually declares functions not local variables. ●global Password  cr eates a global variable called Password●Password = "password"  cr eates a local variable called Password .In some programming languages if you declare a variable in your code and it is not inside a subroutine or function, then it is assumed to be global. Therefore you need to be careful when declaring variables. The following extract of code shows how you might set Password as a global variable and then other variables as local in Visual Basic: 4 Subroutines, local and global variables 26Public Password As String Private Sub CalculateMathsGradeDim Score As IntegerDim Grade As StringIf Score > 50 then Grade = "Pass"Else Grade = "Fail"End SubPrivate Sub CalculateEnglishGrade Dim Score As IntegerDim Grade As StringIf Score > 50 thenGrade = "Pass" ElseGrade = "Fail" End subThere are two subroutines: CalculateMathsGrade  and CalculateEnglishGrade.  The variable Password  is a global variable and therefore is accessible from either of the two subroutines. The Score and Grade  variables are local to each subroutine. This means that although they have the same names in both, they are actually different variables containing different values, a bit like having two people called John Smith with different characteristics.
 ●Exception handlingThere are many situations where a subroutine has to stop because of anexceptional circumstance that causes an error. This is not necessarily anunexpected event, just one that causes the current subroutine to stop. Anexample would be a division by 0 error, where the subroutine is expecting anumber, but instead gets an undefined value caused by the division. Whenthis happens, the subroutine has been ‘thrown’ an error, which it must dealwith. If it is unable to ‘catch’ the error, the program could produce a fatalerror, causing the program to stop running completely.In the same way that subroutines are triggered by events, there need to be blocks of code that handle errors that are triggered whenever the erroroccurs. These are often referred to as catch blocks, which are specific blocksof code that are triggered in response to specific errors.
 The normal procedure when this happens is: ●an error is thrown so the current subroutine stops or is paused●the current state of the subroutine is saved ●the exception handling code (or catch block) is executed to take care ofthe error ●the normal subroutine can then be run again, picking up from where it was saved.KEYWORD Exception handling: the process of dealing w ith events that cause the current subroutine to stop.A level onlyEXCEPTION HANDLING 27Exceptionunexpected ExceptionexpectedNormal program flow Exception handlerException Fatal program err orFigure 4.2 The exception handling process Practice questions can be found at the end of the section on pages 46 and 47. TASKS1 Define the following terms and explain the difference between the two: a) subroutine b) function.
 2 Give examples of in-built functions that you might find in a  programming language.3 Why is it good practice to construct programs using subroutines?4 What is the advantage of using functions? 5 Define the following terms and explain the difference between the two: a) algorithm b) code.
 6 What is a module and how does it differ from a subroutine?7 Explain how parameters and arguments are used to pass values and variables into subroutines.8 What is a block interface? 9 Why is it good practice to use local variables whenever possible?10  Give an example of where you might use a global variable. 11  Explain how an exception handler works.
 STUDY / RESEARCH TASKS1 Write a program that calculates the square and square root of any given number. Try to include the following features: a)a subroutineb)a function c)a subroutine or function calld)a parameter or argument e)a local variablef)a global variable.2 Extend your program to include other common mathematical functions. 3 Write a program that takes in a set of numbers and then calculates the  mean, median and range using either in-built or user-deﬁned functions.4 Find examples of typical events that would require exception handling code.KEY POINTS •Subroutines or proceduresare a way of breaking up code into manageable blocks ofcode, each of which performsa speciﬁc task. •Subroutines are likely to haveother related subroutines. •Breaking a program up intosubroutines is beneficial for several reasons, mainlyrelated to being easier tomanage and maintain theprogram.•A function is a type ofsubr outine that returns a setvalue, for example, the squareroot function. •Parameters and argumentsare the data that are passed into the function on which itperforms its computations.
 •Local variables can only beused within the subroutine in which they were created.
 •Global variables can be usedanywhere in a program. •Exception handling is the wayin which the program deals with events that may cause itto stop.
User: Make the following text more clear.
Format it properly.
Do NOT change the meaning of the words or methods used to obtain the answer or anything like that.
This is for AQA A(S)-Level Computer Science. I repeat, do not alter the words as it could have an effect on the marks acquired from the marking scheme.
However, remove any redundant information or USELESS examples that are not needed for a student to know, or simplify unnecessary information (if it has a definition or keywords, it is not unnecessary).
If you can, use different values for the examples.
For things that will not score a mark or are generally useless, for example, "we will cover" or a fun fact, change the wording.
Link the 'sections' of your answer to the following spec-points (by title):
e.g. "**Topic** (Spec Points: a.b.c. Whatever)
3.1.1.9 Exception handling
None

3.1.1.13 Local variables in subroutines
None

3.1.1.10 Subroutines (procedures/functions)
None

3.1.1.14 Global variables in a programming language
None

3.1.1.11 Parameters of subroutines
None

3.1.1.12 Returning a value/values from a subroutine
None


You MUST make sure they are ALL met. Everything it says on there you should meet.

I already provided the available exam questions you MAY choose to add on to the notes, with 'des' explaining what it's about, and 'fil' meaning the Question ID.
The content, too. Delivered in the form 'fil', JSON
Ignore exam questions that contain 'Skeleton Program'. Do not only put like 2 exam questions, try to put more!
For the exam questions, in the original text, there is a label named 'Tasks'. Those (usually) six questions are NOT the exa questions. The exam questions are the ones that were given in JSON form to you, do NOT do the 'Tasks'. Do the exam questions that contain HTML in JSON!

In the markscheme, a ';' typically means that a mark was gained.
When mentioning exam questions, you *must* answer them, according to the markscheme, scoring full marks. No 'do it yourself'.

If necessary for scoring marks, try to embed the exam-questions into your notes, sometimes without even referencing the fact that it is an exam question. For example, if an exam question is a definition or benefits, use the answer in your notes.
Remember. DO NOT ADD USELESS STUFF. Your task is to create the MOST EFFICIENT (SHORTEST [for an explanation] BUT STILL SCORES ALL MARKS) possible notes resource, which will score all marks easily, so its wording has to be mostly like that of the exam questions. By any means, if necessary, please include examples and exam questions! At the end you can have a 'try these exam questions' thing.
At the end of your answer, you will give a 'breakdown'/'summary' of each thing you covered which will tell the most concise FULLY MARK-SCORING explanation possible.

In summary, your answer must:

* Be efficient, useful
* For topics in an exam that may require some form of mathematical working, always show an example of a question.
* Be clear – provide clear, step-by-step examples/instructions when needed.
* Follow the entire specification and everything it says.
* Link your section to a spec point. E.g. **Topic** (Spec Points: a.b.c Whatever)
* Score ALL marks.
* Include ALL exam questions S at the end (except ones that contain 'Skeleton Program'), with the same wording as the original ones in the JSONs sent to you – and INCLUDE THE QUESTION CONTENT, AND THE ANSWERS/MARK SCHEME. Only the ones that I provided to you, include Question IDs.
* Remove redundant, unnecessary and useless information that would not be brought up in an exam answer.
* Be helpful to the reader
* Include a summary at the end that goes through everything you need to score all marks.

At the end of the formatted text, after everything is done, fill out the JSON:
Remove the type clarification.
{
"chapter": (int),
"page": (int),
"chapter_name": (str),
"topics": (list)
}

User: And these are the available exam questions, with 'des' explaining what it's about, and 'fil' meaning the Question ID.
{'S1$.1.i': [{'index1': '|D.A$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.i', 'index5': '|', 'index6': 'Q22S1B10p1', 'qid': 'Q22S1B10p1', 'des': 'Explain what exception handling is used for', 'index7': '', 'marks': '2 marks', 'time': '3', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'Q22S1B10P1', 'year': 2023, 'res': '', 'flag1': None}, {'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.i', 'index5': '|19$|', 'index6': 'Q22S1B10p2', 'qid': 'Q22S1B10p2', 'des': 'State identifier of subroutine that performs exception handling and give exception example', 'index7': '', 'marks': '2 marks', 'time': '3', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q22S1B10P2', 'year': 2023, 'res': '/RESOURCES/AA_COM/RESOURCES/2022_AS_SectionB_resources.html', 'flag1': None}, {'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.i | S2$.1.c', 'index5': '|12$|', 'index6': 'Q20S1B07', 'qid': 'Q20S1B07', 'des': 'Describe two possible file errors that could cause exception in Skeleton Program', 'index7': '', 'marks': '2 marks', 'time': '2', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q20S1B07', 'year': 2020, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Section_B_Summer2020.html', 'flag1': None}, {'index1': '|D.A$|D.C$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.i', 'index5': '|2$|', 'index6': 'QS19S1B06', 'qid': 'QS19S1B06', 'des': 'Exception handling', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts | Practical programming | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS19S1B06', 'year': 2019, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2019.html', 'flag1': 1}], 'S1$.1.m': [{'index1': '|D.A$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.m | S1$.1.n', 'index5': '|', 'index6': 'Q23S1A03', 'qid': 'Q23S1A03', 'des': 'Local variable; global variable', 'index7': '', 'marks': '2 marks', 'time': '3', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'Q23S1A03', 'year': 2023, 'res': '', 'flag1': 0}, {'index1': '|D.A$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.m | S1$.1.n', 'index5': '|', 'index6': 'QS19S1A01', 'qid': 'QS19S1A01', 'des': 'Compare global and local variables; scope', 'index7': '', 'marks': '3 marks', 'time': '4', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'QS19S1A01', 'year': 2019, 'res': '', 'flag1': 1}, {'index1': '|D.A$|D.C$|K$|', 'index2': '|1$|', 'index3': '2$', 'index4': 'S1$.1.m', 'index5': '|16$|', 'index6': 'QS18S1B06', 'qid': 'QS18S1B06', 'des': 'Local variables; global variables', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts | Practical programming | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS18S1B06', 'year': 2018, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2018.html', 'flag1': 1}], 'S1$.1.j': [{'index1': '|D.A$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.j', 'index5': '|', 'index6': 'Q22S1B11p1', 'qid': 'Q22S1B11p1', 'des': 'What is a subroutine?; function; procedure', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'Q22S1B11P1', 'year': 2023, 'res': '', 'flag1': None}, {'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.j', 'index5': '|19$|', 'index6': 'Q22S1B11p2', 'qid': 'Q22S1B11p2', 'des': 'Give an example of re-use of a subroutine in the skeleton program; function; procedure', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q22S1B11P2', 'year': 2023, 'res': '/RESOURCES/AA_COM/RESOURCES/2022_AS_SectionB_resources.html', 'flag1': None}, {'index1': '|D.A$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.j', 'index5': '|', 'index6': 'Q22S1B11p3', 'qid': 'Q22S1B11p3', 'des': 'Describe advantage of re-using subroutines; function; procedure', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'Q22S1B11P3', 'year': 2023, 'res': '', 'flag1': None}, {'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '3$', 'index4': 'S1$.1 | S1$.1.a | S1$.1.b | S1$.1.j | S1$.1.l', 'index5': '|12$|', 'index6': 'Q20S1B04', 'qid': 'Q20S1B04', 'des': 'State identifiers of variables and subroutines in the Skeleton Program; Boolean; string', 'index7': '', 'marks': '3 marks', 'time': '4', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q20S1B04', 'year': 2020, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Section_B_Summer2020.html', 'flag1': None}, {'index1': '|D.A$|D.C$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.a | S1$.1.b | S1$.1.f | S1$.1.j | S1$.1.l', 'index5': '|2$|', 'index6': 'QS19S1B04', 'qid': 'QS19S1B04', 'des': 'Boolean variables and subroutines', 'index7': '', 'marks': '2 marks', 'time': '2', 'ttext': 'Programming concepts | Practical programming | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS19S1B04', 'year': 2019, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2019.html', 'flag1': 1}, {'index1': '|D.A$|', 'index2': '|1$|', 'index3': '3$', 'index4': 'S1$.1.f | S1$.1.j | S1$.1.n | L1$.1.f | L1$.1.j | L1$.1.n', 'index5': '|', 'index6': 'QS0516B', 'qid': 'QS0516B', 'des': 'Variables; self-contained functions', 'index7': '', 'marks': '2 marks', 'time': '3', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'QS0516B', 'year': 2005, 'res': '', 'flag1': 0}, {'index1': '|D.A$|', 'index2': '|1$|', 'index3': '3$', 'index4': 'S1$.1.b | S1$.1.j | S1$.1.k | L1$.1.b | L1$.1.j | L1$.1.k', 'index5': '|', 'index6': 'QS02106', 'qid': 'QS02106', 'des': 'Reasons for procedures; parameters', 'index7': '', 'marks': '3 marks', 'time': '5', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'QS02106', 'year': 2002, 'res': '', 'flag1': 0}], 'S1$.1.n': [], 'S1$.1.k': [{'index1': '|D.A$|D.C$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.k', 'index5': '|2$|', 'index6': 'QS19S1B07', 'qid': 'QS19S1B07', 'des': 'Parameters of a subroutine', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Programming concepts | Practical programming | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS19S1B07', 'year': 2019, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2019.html', 'flag1': 1}, {'index1': '|D.A$|', 'index2': '|1$|', 'index3': '3$', 'index4': 'S1$.1.k | S1$.1.n | L1$.1.k | L1$.1.n', 'index5': '|', 'index6': 'QS00N103', 'qid': 'QS00N103', 'des': 'Parameters/global variables', 'index7': '', 'marks': '3 marks', 'time': '5', 'ttext': 'Programming concepts', 'fld': 'AA_COM', 'fil': 'QS00N103', 'year': 0, 'res': '', 'flag1': 0}], 'S1$.1.l': [{'index1': '|D.A$|D.C$|K$|', 'index2': '|1$|', 'index3': '2$', 'index4': 'S1$.1.a | S1$.1.b | S1$.1.f | S1$.1.l', 'index5': '|16$|', 'index6': 'QS18S1B04', 'qid': 'QS18S1B04', 'des': 'Variable type; subroutine return value', 'index7': '', 'marks': '2 marks', 'time': '2', 'ttext': 'Programming concepts | Practical programming | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS18S1B04', 'year': 2018, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2018.html', 'flag1': 1}]}

User: These are the content of said exam questions, these are the ONLY exam questions, you will use these later, delivered in form 'fil', JSON: {'Q22S1B10P1': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Explain what exception handling is used for.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>2 marks for AO1 (understand)</b></p>\r\n<p class="indent1new indentright">To stop a program from crashing;</p>\r\n<p class="indent1new indentright m-t-0">To deal with (an anticipated) <u>run-time</u> error&emsp;<b>A.</b> clear description of an example of a run-time error;</p>\r\n<p class="indent1new indentright m-t-0">To avoid structure of code becoming too complex as a result of trying to check for potential errors before they might occur;</p>\r\n<p class="indent1new indentright"><b>Max 2</b></p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Most students secured the first mark of this question by identifying that an exception stops a program from crashing. Many fewer students recognised that exception handling is relevant to run time errors. &#x0027;Errors&#x0027;, in isolation, did not demonstrate a sufficient level of understanding.</p></h5>', 'notes': '', 'resources': ''}, 'Q22S1B10P2': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">State the identifier of a subroutine in the <b>Skeleton Program</b> that performs exception handling <b>and</b> give an example of a circumstance that might cause an exception within that subroutine.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>2 marks for AO2 (analyse)</b> <b> <BR></b><b>1 mark for identifier and 1 mark for exception</b></p>\r\n<p class="indent1new indentright"><span class="comp">LoadPuzzleFile</span> &#x2013; file does not exist // index error if more lines in file than <span class="comp">Puzzle</span> can accommodate;</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">LoadSolution</span> &#x2013; file does not exist // not enough lines in file;</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">TransferPuzzleIntoGrid</span> &#x2013; input conversion error // index error if string length &lt; 3;</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">LoadPartSolvedPuzzle</span> &#x2013; file does not exist // index error if more lines in file than</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">Answer</span> can accommodate;</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">SolvePuzzle</span> &#x2013; row/column/1<sup class="xsmall">st</sup> character/2<sup class="xsmall">nd</sup> character entered not a digit/number/integer // input conversion error;</p>\r\n<p class="indent1new indentright"><b>A.</b> <span class="comp">KeepPuzzle</span> &#x2013; file does not exist (Java only)</p>\r\n<p class="indent1new indentright m-t-0"><b>A.</b> <span class="comp-top">readLine</span> &#x2013; end of file (Java only)</p>\r\n<p class="indent1new indentright"><b>A.</b> other exceptions that could occur</p>\r\n<p class="indent1new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent1new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent1new indentright m-t-0"><b>I.</b> case and spacing</p>\r\n<p class="indent1new indentright"><b>Max 2</b></p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The majority of students were able to identify a subroutine that performed exception handling, as required by this question. Of those who correctly identified the subroutine, most were able to identify a relevant circumstance that might cause an exception.</p>\r\n<p class="indent1new">The most common reason for dropping a mark on this question was to give more than just the subroutine&#x0027;s name. For example, <span class="comp">LoadPuzzleFile</span> was creditworthy, whereas <span class="comp">def LoadPuzzleFile</span> or <span class="comp">LoadPuzzleFile(PuzzleName, Puzzle)</span> was not.</p></h5>', 'notes': '', 'resources': ''}, 'Q20S1B07': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question refers to the subroutine <span class="comp">LoadGreyScaleImage</span></p>\r\n<p class="indent1new">Describe <b>two</b> possible errors that could cause an exception in this subroutine.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>All marks for AO2 (analyse)</b> </p>\r\n<p class="indent1new indentright"><span class="comp">NextPixel</span> is not (a string that can be converted to) an integer;</p>\r\n<p class="indent1new indentright m-t-0">File no longer available; <b>R.</b> file could not be opened as already open</p>\r\n<p class="indent1new indentright m-t-0">Pixel data stored in wrong format, <b>R.</b> file does not have .txt extension;</p>\r\n<p class="indent1new indentright m-t-0">Not enough lines in the file <b>N.E.</b> Empty file<b>;</b> </p>\r\n<p class="indent1new indentright m-t-0">Not enough characters in a line;</p>\r\n<p class="indent1new indentright m-t-0"><b>A.</b> Not enough data in file for given size of image; if neither of the 2 points above have been given</p>\r\n<p class="indent1new indentright m-t-0"><u>Header</u> height larger than <span class="comp">MAX_HEIGHT</span>, <b>A.</b> larger than 100;</p>\r\n<p class="indent1new indentright m-t-0"><u>Header</u> width larger than <span class="comp">MAX_WIDTH</span>, <b>A.</b> larger than 100;</p>\r\n<p class="indent1new indentright"><b>Max 2</b></p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '', 'notes': '', 'resources': ''}, 'QS19S1B06': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">What is the specific purpose of the exception handling construct in the subroutine <span class="comp">SetUpBoard</b>?</span></p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent1new">catch any <u>file</u> errors // stop program crashing if <u>file doesn’t exist</u>;</p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Many students’ answers were very vague as to the reasons for using exception handling in the subroutine <span class="comp">SetUpBoard</span>. Answers that were given credit included stating that this would avoid a program crash in case of file errors.</p></h5>', 'notes': '', 'resources': ''}, 'Q23S1A03': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Describe <b>one</b> difference between a global variable and a local variable.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>2 marks for AO1 (knowledge)</b></p>\r\n<p class="indent1new">Global variable can be used anywhere in program // global variable is declared in outmost block / outside subroutines;</p>\r\n<p class="indent1new m-t-0">Local variable can only be used in the block / subroutine in which it is declared;</p>\r\n<p class="indent1new"><i><b>Alternative answer 1:</b> </i></p>\r\n<p class="indent1new">Local variables only use memory when the program block they are in is executing; global variables use memory the entire time the program is executing;</p>\r\n<p class="indent1new"><i><b>Alternative answer 2:</b></i></p>\r\n<p class="indent1new">Local variables only exist when the program block they are in is executing; global variables exist the entire time the program is running;</p>\r\n<p class="indent1new"><b>A.</b> local variables are stored on a stack / in a stack frame; global variables are generally stored elsewhere in the memory;</p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question required students to describe a difference between a global and a local variable, and fewer than half of students succeeded in providing a description that secured both marks. Although there was an understanding that the scope of a local variable is more limited, this was often phrased too vaguely to be fully creditworthy.</p></h5>', 'notes': '', 'resources': ''}, 'QS19S1A01': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">State <b>one</b> difference between local and global variables and give <b>two</b> reasons why it is good practice to use local variables.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 3 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>All marks for AO1 (knowledge)</b></p>\r\n<p class="indent1new">Difference:</p>\r\n<p class="indent1 indentright m-t-0">global variables accessible to all parts of the program</p>\r\n<p class="indent1 indentright m-t-0">// declared in main program block</p>\r\n<p class="indent1 indentright m-t-0">// local variables declared in subroutine</p>\r\n<p class="indent1 indentright m-t-0">// accessible only in the program block/subroutine in which it was declared;</p>\r\n<p class="indent1new">Reason:</p>\r\n<p class="indent1 indentright m-t-0">memory allocated to local variables can be reused when subroutine not in use;</p>\r\n<p class="indent1 indentright m-t-0">local variable only exists while the program block/subroutine is executing;</p>\r\n<p class="indent1 indentright m-t-0">using local variables makes subroutines self-contained;</p>\r\n<p class="indent1 indentright m-t-0"><b>A.</b> prevents accidental changes;</font></p>\r\n<p class="indent1 indentright m-t-0"><b>A.</b> easier debugging/maintenance;</font></p>\r\n<p class="indent1 indentright m-t-0"><b>Max 2</b></p>\r\n<p class="mark">[3]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Many vague answers were given for the difference between local and global variables. Regardless of how the student’s chosen programming language requires local / global variables to be declared, students need to be aware that a global variable is accessible to all parts of the program, whereas a local variable is accessible only in the program block in which it was declared. Many students’ answers were very vague as to the reasons for using local variables. Some were able to state that memory used to store local variables is released when the subroutine terminates, but very few mentioned that local variables make a subroutine self-contained and therefore it is easier to re-use such subroutines in other programs.</p></h5>', 'notes': '', 'resources': ''}, 'QS18S1B06': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Several subroutines use a variable <span class="comp">TransmissionLength</span>. It could have been declared as a global variable instead of locally in each subroutine.</p>\r\n<p class="indent1new">Why is it good practice to use local variables?</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question indentright"><b>Mark is for AO1 (understanding)</b></p>\r\n<p class="indent1 indentright indentright">1.&emsp;&ensp;&nbsp;makes a subroutine self-contained;</p>\r\n<p class="indent1 m-t-0 indentright">2.&emsp;&ensp;&nbsp;releases storage when subroutine terminates;</p>\r\n<p class="indent1 m-t-0 indentright">3.&emsp;&ensp;&nbsp;able to test / debug subroutine independently;</p>\r\n<p class="indent1 m-t-0 indentright">4.&emsp;&ensp;&nbsp;easier to re-use subroutine in another program;</p>\r\n<p class="indent1 m-t-0 indentright">5.&emsp;&ensp;&nbsp;local variable values cannot be inadvertently/accidentally altered by a subroutine call from the subroutine;</p>\r\n<p class="indent1new indentright"><b>Max 1</b></p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Many students’ answers were very vague as to the reasons for using local variables. Some were able to state that memory used to store local variables is released when the subroutine terminates, but very few mentioned that local variables make a subroutine self-contained and therefore it is easier to re-use a subroutine in another program.</p></h5>', 'notes': '', 'resources': ''}, 'Q22S1B11P1': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">What is a subroutine?</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO1 (knowledge)</b></p>\r\n<p class="indent1new indentright">Named / (reference to) identifier / callable &#8216;out of line&#8217; block of code (that may be called by simply writing its name in a program statement);</p>\r\n<p class="indent1new indentright"><b>A.</b> subroutine is used to give a block of code a name (and this name can be used to execute this group of statements)</p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Many students dropped the mark on this question by providing an incomplete answer. Only a very small number of answers were incorrect, but many more were incomplete. Stating only that a subroutine is a named section of code was insufficient on its own, and was a commonly-given answer.</p></h5>', 'notes': '', 'resources': ''}, 'Q22S1B11P2': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The use of subroutines promotes code re-use.</p>\r\n<p class="indent1new">Describe, with references to subroutine(s) in the <b>Skeleton Program</b>, an example of how a subroutine has been re-used.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO2 (analyse)</b></p>\r\n<p class="indent1new indentright"><span class="comp">LoadPuzzle</span> is called more than once (from <span class="comp">NumberPuzzle</span> and also from <span class="comp">LoadPartSolvedPuzzle</span>)</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">// DisplayGrid</span> is called more than once (from within <span class="comp">SolvePuzzle</span>)</p>\r\n<p class="indent1new indentright m-t-0"><span class="comp">//ResetDataStructures</span> is called more than once (from <span class="comp">NumberPuzzle</span> and twice from <span class="comp">LoadPuzzle</span>);</p>\r\n<p class="indent1new indentright"><b>A.</b> <span class="comp">readLine / print</span> is called more than once (Java only)</p>\r\n<p class="indent1new indentright m-t-0"><b>NE.</b> &#8216;called more than once&#8217; without an appropriate subroutine name</p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The majority of students secured the mark for this question.</p></h5>', 'notes': '', 'resources': ''}, 'Q22S1B11P3': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Describe an advantage of re-using subroutines.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO1 (understanding)</b></p>\r\n<p class="indent1new indentright">Saves time as code can be written once and called in many places;</p>\r\n<p class="indent1new indentright m-t-0">Reduced storage space of (source) code;</p>\r\n<p class="indent1new indentright m-t-0">Reduces testing time as less code to test;</p>\r\n<p class="indent1new indentright m-t-0">Avoids errors because code cannot be written differently if it is used in multiple places; Program code will be easier to understand / maintain;</p>\r\n<p class="indent1new indentright"><b>MAX 1</b></p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question was another question for which responses scoring zero were more likely to be incomplete than incorrect. Students were asked to describe rather than state, showing understanding rather than knowledge. As such, &#x0027;reduces testing time&#x0027; was insufficient, whereas &#x0027;reduces testing time due to less code to test&#x0027; secured the mark.</p></h5>', 'notes': '', 'resources': ''}, 'Q20S1B04': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">State the name of an identifier for:</p>\r\n<p class="indent1">(a)&emsp;&nbsp;a variable that is used to store a Boolean value.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;a user-defined subroutine that returns only <b>one</b> value that <b>must</b> be a string.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(c)&emsp;&nbsp;a user-defined subroutine that uses nested <b>indefinite</b> iteration.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 3 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b> </p>\r\n<p class="indent2new indentright comp-top">FileFound / FileTypeOK / ProgramEnd;</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new indentright m-t-0"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b> </p>\r\n<p class="indent2new indentright"><span class="comp">ConvertChar</span> //</p>\r\n<p class="indent2new indentright m-t-0"><span class="comp">GetMenuOption</span> (Python only);</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new indentright m-t-0"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(c)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent2new indentright comp-top">EditImage;</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new indentright m-t-0"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p>\r\n<p class="mark">[3]</p></h5>', 'examinerreport': '', 'notes': '', 'resources': ''}, 'QS19S1B04': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">State the name of an identifier for:</p>\r\n<p class="indent1new">(a)&emsp;&nbsp;a variable that is used to store a Boolean value.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">(b)&emsp;&nbsp;a user-defined subroutine that returns a single Boolean value.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent2new comp-top">Valid</p>\r\n<p class="indent2new comp">/ValidPiece</p>\r\n<p class="indent2new comp">/ValidMove</p>\r\n<p class="indent2new comp">/Found</p>\r\n<p class="indent2new comp">/EndOfList</p>\r\n<p class="indent2new comp">/Jumping</p>\r\n<p class="indent2new comp">/GameEnd</p>\r\n<p class="indent2new comp">/FileFound;</p>\r\n<p class="indent2new m-t-0"><b>A.</b> <span class="comp">CanJump;</span></p>\r\n<p class="indent2new"><b>R.</b> if any additional code</p>\r\n<p class="indent2new m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new m-t-0"><b>I.</b> case &#38; spacing</p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">(b)&emsp; <b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent2new comp-top">/ValidMove</p>\r\n<p class="indent2new comp">/ValidJump</p>\r\n<p class="indent2new comp">/ListEmpty;</p>\r\n<p class="indent2new"><b>A.</b> <span class="comp">setUpBoard</span> (for Java only)</p>\r\n<p class="indent2new m-t-0"><b>R.</b> if any additional code</p>\r\n<p class="indent2new m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new m-t-0"><b>I.</b> case &#38; spacing</p>\r\n<p class="levelms">1</p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The majority of students secured both of the marks for this question. A few students copied across more than just the identifier for each part and therefore did not gain the mark as it was not clear which part of the copied code they believed the identifier to be.</p></h5>', 'notes': '', 'resources': ''}, 'QS0516B': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The following code is part of a high level program</p>  \r<p class="indent1new">&nbsp;&nbsp;Var Name: String;</p>  \r<p class="indent1new m-t-0">&nbsp;&nbsp;Var Hours: Integer;</p>  \r<p class="indent1new m-t-0">&nbsp;&nbsp;Var RateOfPay: Real;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent1new m-t-0">Function CalculatePay(InHours: Integer; InRateOfPay: Real): Real;</p>  \r<p class="indent1new m-t-0">&nbsp;&nbsp;Var Total: Real;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent2new m-t-0">&#42;</p>  \r<p class="indent2new m-t-0">&#42;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(a)&nbsp;&nbsp;&nbsp;&nbsp; Procedures and functions are often <i>self-contained</i>. What is meant by the term self-contained in this context?</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">&nbsp;(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; Give <b>one</b> reason why the use of global variables may introduce program bugs.</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(1)</p>  \r<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1 indentright m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; Do not use any global variables// use only local variables and/or parameters;</p>  \r<p class="indent2new indentright m-t-0"><b>A </b>Can be compiled independently // can be placed in a library</p>  \r<p class="levelms">1</p>  \r<p class="indent1 indentright">(b)&nbsp;&nbsp;&nbsp;&nbsp; Local and global variables with the same name can be misidentified//difficult to test individual procedures/ functions//</p>  \r<p class="indent2new indentright m-t-0">Not clear that as a side-effect of executing procedure/function a global variable could change its value;</p>  \r<p class="levelms">1</p>  \r<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question showed that many candidates have not had sufficient exposure to programming techniques.</p>  \r<p class="indent1new">Parts (a) and (b) often showed up the candidates’ inability to express themselves clearly.</p>  \r<p class="indent1">(a)&nbsp;&nbsp;&nbsp;&nbsp; Many candidates described recursion. Those that didn’t often restated the question. Only the very best candidates were able give a satisfactory answer.</p>  \r<p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; The responses to this part were also very disappointing. Answers were often irrelevant and/or badly expressed.</p></h5>', 'notes': '', 'resources': ''}, 'QS02106': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The structured approach when writing programs uses functions and procedures.</p>  \r<p class="indent1">(a)&nbsp;&nbsp;&nbsp;&nbsp; Give two reasons why procedures are used.</p>  \r<p class="indent2new answer-toggle">1. _________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">2. _________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(2)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; What are parameters used for in the context of procedures and functions?</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(1)</p>  \r<p class="mark">(Total 3 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1 indentright m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; To give a set of statements a name;</p>  \r<p class="indent2new indentright m-t-0">To avoid repeating code; procedures can be called up many times; so a program may be developed by more than one programmer;</p>  \r<p class="indent2new indentright m-t-0">To enable top-down development;</p>  \r<p class="indent2new indentright m-t-0">To enable stub-testing; so libraries of code written by other programmers may be used;</p>  \r<p class="indent2new indentright m-t-0">For creating libraries of code;</p>  \r<p class="indent2new indentright m-t-0">Allows for modular programming; allows for modular testing;</p>  \r<p class="indent2new indentright m-t-0">To make program easier to debug / maintain / understand;</p>  \r<p class="levelms">Max 2</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&nbsp;&nbsp;&nbsp;&nbsp; To pass <u>data/value</u> within programs / to pass <u>data/value</u> in and out of procedures/functions;</p>  \r<p class="levelms">1</p>  \r<p class="mark">[3]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The few candidates who studied the topic had no difficulty answering this question. Those who had not, often assumed that ‘procedure’ was a method of programming, ‘parameters’ were a set of rules or limits beyond which the program could not go. It is important that candidates gain some experience of programming with functions and procedures and appreciate the role of parameters in passing data into / out of these subroutines. A creditworthy response was that the use of procedures avoided repeating code because a procedure could be called up many times from different parts of the program.</p></h5>', 'notes': '', 'resources': ''}, 'QS19S1B07': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question refers to the subroutines <span class="comp">Game</span> and <span class="comp">ListPossibleMoves</span>.</p>\r\n<p class="indent1new">Describe what is contained in the parameter <span class="comp">PlayersPieces</span> when <span class="comp">ListPossibleMoves</span> is called for the first time in the subroutine <span class="comp">Game</span>.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO2 (analyse)</b></p>\r\n<p class="indent1new">positions of player A’s pieces;</p>\r\n<p class="indent1new indentright m-t-0"><b>A.</b> the contents of (the data structure/variable) <span class="comp">A //</span> pointer/address to <span class="comp">A // A;</span></p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Less able students stated that it was the player’s pieces that would be contained in the parameter. To earn this mark, a reference to the positions of player A’s pieces was required.</p></h5>', 'notes': '', 'resources': ''}, 'QS00N103': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1a m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; (i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; What is meant by a <i>parameter</i> of a procedure?</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2">(ii)&nbsp;&nbsp;&nbsp;&nbsp; What is meant by a <i>global variable</i>?</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; When writing a procedure, why might a programmer prefer to use parameters rather than global variables?</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(1)</p>  \r<p class="mark">(Total 3 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1a indentright m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; (i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value passed into, or out of, procedure from / to calling program</p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright">(ii)&nbsp;&nbsp;&nbsp;&nbsp; Variable defined outside any procedure and so in scope for whole program </p>  \r<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&nbsp;&nbsp;&nbsp;&nbsp; Saves memory since parameter takes no space when not in use</p>  \r<p class="indent2new indentright m-t-0">Enables portability of procedures / blackbox programming / incorporation of procedures into library</p>  \r<p class="indent2new indentright m-t-0">Enables re-using of variable / identifier names for formal parameters without interfering with other procedures </p>  \r<p class="indent2new indentright m-t-0">Passing by value prevents accidental alteration of a value having unexpected side-effects in other procedures<br><i>1 mark for a relevant point</i></p>\r<p class="levelms">1</p>  \r<p class="mark">[3]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Parameters are clearly widely misunderstood - many answers reflected the common misunderstanding of the word as “boundaries” rather than context-determining factors. Almost any answer about passing data to / from procedures or functions would do. Most, on the other hand, understood global variables. Answers to (b) were not encouraging, probably because parameters are misunderstood - the best answers were either the use of portable procedures and the ability to include them in libraries for re-use, or the saving of memory by discarding variables not currently in use. Another popular correct answer is the risk of a procedure accidentally altering a global and therefore having unexpected side effects in other procedures.</p></h5>', 'notes': '', 'resources': ''}, 'QS18S1B04': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">State the name of an identifier for:</p>\r\n<p class="indent1">(a)&emsp;&nbsp;a variable that is used to store a Boolean value.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;a user-defined subroutine that returns a single character.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona indentright">(a)&emsp;&nbsp;<b>Mark is for AO1 (understanding)</b></p>\r\n<p class="indent2new comp-top indentright">LetterEnd // ProgramEnd ;</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new m-t-0 indentright"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new m-t-0 indentright"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>Mark is for AO1 (understanding)</b></p>\r\n<p class="indent2new indentright"><span class="comp-top">GetMenuOption // Decode ;</span> <b>A.</b> <span class="comp-top">GetNextSymbol</span></p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new m-t-0 indentright"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new m-t-0 indentright"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p> \r\n<p class="mark">[2]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The majority of students secured both of the marks for this question. A few students copied across more than just the identifier for each part and therefore did not gain the mark as it was not clear which part of the copied code they believed the identifier to be.</p></h5>', 'notes': '', 'resources': ''}}
User: Now, the user will ask questions after this message. Use everything I gave you and the knowledge you have acquired, and from the notes you made, to answer their question in a very concise way that WILL score ALL marks. Just like the notes. For this, your answer will not have the same structure as the revision notes. Think of it as answering an exam question: short, consice, useful, scores ALL marks. Just like the exam questions provided to you, you will not leave your response in a 'notes' manner. You are just answering an exam question: which means it has to be very short unless explicitly specified by the user that it must be long and detailed. So, keep it short, concise, and only a couple of sentences that score ALL marks. Remember, it is an A-Level exam question and you will style it as such: incredibly concise sentences (essentially like bullet points but without the bullet points) that score marks. Most sentences won't even have commas, this does not mean you can't use them. Also do not repeat the question in your answer, just do it. Score all marks, assume how many marks there are based on the question if it is not provided to you. Imagine that for every sentence you make, you score a mark (for simpler questions), for high (>5 mark) questions that may differ.
In summary, you must:
* Answer very concisely. Kind of like bullet points but as a short para. Most of the time, a sentence, or point, will be a mark.
* Do not repeat the question at the start.
* Don't over-do your answer. Please. 1 mark (e.g., usually, 'What' questions) is like one very short sentence usually. Remember the summary from the notes? Your answer will essentially be like that for most questions but a bit (a bit!) more developed. Remember, this is just A-Levels. Use some of the exam questions that I provided as an example of how you should model your answers.
* When you're listing examples, don't list every example in the universe.
* Score all marks. Be helpful.
User: Write the notes you made
Assistant: