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. This is for AS Level, do not include information about topics that are ONLY A-Level Content (if it says it is)
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
Content
Additional information
Be familiar with the concept of exception handling.
Know how to use exception handling in a programming language with which students are familiar.

3.1.1.13 Local variables in subroutines
Content
Additional information
Know that subroutines may declare their own variables, called local variables, and that local variables:
exist only while the subroutine is executing
are accessible only within the subroutine.
Be able to use local variables and explain why it is good practice to do so.

3.1.1.11 Parameters of subroutines
Content
Additional information
Be able to describe the use of parameters to pass data within programs.
Be able to use subroutines with interfaces.

3.1.1.12 Returning a value/values from a subroutine
Content
Additional information
Be able to use subroutines that return values to the calling routine.

3.1.1.14 Global variables in a programming language
Content
Additional information
Be familiar with and be able to use:
addition
subtraction
multiplication
real/float division
integer division, including remainders
exponentiation
rounding
truncation.

3.1.1.10 Subroutines (procedures/functions)
Content
Additional information
Be familiar with subroutines and their uses.
Know that a subroutine is a named ‘out of line’ block of code that may be executed (called) by simply writing its name in a program statement.
Be able to explain the advantages of using subroutines in programs.


You MUST make sure they are ALL met. Everything it says on there you should meet.
SOMETIMES the specification does not always mention everything. If you encounter something from the body of text that is not necessarily mentioned on the specification point, still try to include it but condense it. Do not make the notes unecessary or useless.

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'.

Include ALL definitions (KEYWORDS) from the original text I sent in your notes. When I mean all, I mean ALL.

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
* Provide the full notes, covering ALL spec-points (and showing the spec-points covered in each section).
* Include ALL definitions (KEYWORDS, usually represented explicitly and specifically in the original text as Keyword: Definition), do not change the wording (unless that definition is an exam question). MAKE ALL THE DEFINITIONS FULL (yet consice, as they can sometimes even be 2 marks). Incorporate the definitons into the notes.
* Include a seperate section named 'Definitions' that covers the keywords and their simplest definition that scores all marks. These are (usually) found in the original text.
* Include a summary at the end (after definitions) 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$|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$|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.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}], 'S1$.1.l': [], 'S1$.1.n': [], '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}]}

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': ''}, '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': ''}, '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': ''}, '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': ''}, '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': ''}}
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: