Exam workshop: plan, answer and review
Plan a multipart answer
The report question below is worth six practice points for a complete algorithm. Before coding, list its identifiers and types. Separate storing entries from selecting entries, even if your implementation processes them in one loop. A record is appropriate because a code and a measured value have different types.
Worked example: a model answer, point by point
Question (5 marks): Write pseudocode for a function Band(). It takes an integer Mark as a parameter and returns 'A' for a mark of 70 or more, 'B' for 50 to 69, and 'U' otherwise.
FUNCTION Band(Mark : INTEGER) RETURNS CHAR
IF Mark >= 70 THEN
RETURN 'A'
ELSE
IF Mark >= 50 THEN
RETURN 'B'
ELSE
RETURN 'U'
ENDIF
ENDIF
ENDFUNCTION
OUTPUT Band(70), Band(69), Band(12)
The test line outputs ABU. A mark scheme for this kind of question gives one mark for each of these points:
- The function header, with the parameter and its type, and
RETURNS CHAR. - A correct test for 70 or more, with
>=. - A correct test for 50 to 69.
- Returning each of the three characters.
ENDFUNCTION, with the value returned rather than output.
Point 5 is the one most often lost: OUTPUT 'A' inside a function does not give the caller anything.
Where marks are lost
OUTPUTinstead ofRETURNin a function that "returns" a value.- A missing type:
FUNCTION Band(Mark) RETURNS CHARdrops the parameter type. >where the question says "or more", so the boundary value lands in the wrong band.- Missing
ENDIF,NEXTorENDFUNCTION. Each block keeps its closing keyword. - An array declared too small:
ARRAY[1:3]when four entries can arrive.
Marking checklist
Review each feature: record definition; correctly bounded array; reading every requested entry; inclusive threshold; output in input order; correctly initialised count and final output. A teacher may award partial marks for these features even when a runnable solution fails a case. Our local check awards the complete-algorithm points only when all cases pass.
Attempt, then compare
Try the algorithm without hints. Trace a value below the threshold, one exactly on it, and one above it. After checking, use the authored hints and worked answer to compare decisions. Explain why Code is a STRING and why Count is initialised outside the loop. When ready, attempt assessment A and assessment B without support.
الصعوبة 4/5 · 280 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Read NumberOfEntries (1 to 4), then Target, then NumberOfEntries code/value pairs. Define TYPE Entry with Code : STRING and Value : INTEGER, and store an array of records. Output codes whose Value is at least Target, in input order, then the matching count.
اضغط تشغيل لرؤية المخرجات هنا.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Write FUNCTION Band(Mark : INTEGER) RETURNS CHAR: A for 70 or more, B for 50 to 69, U otherwise. The main program reads one integer and outputs Band() of it.
اضغط تشغيل لرؤية المخرجات هنا.
الصعوبة 4/5 · 280 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
For Target = 10 and values 9, 10, 15, give Count after each iteration. Count starts at 0 and increases for values at least Target.
Explain your choice of data structure and loop. Identify one boundary case and predict its result. For a subroutine, explain what is returned or changed in the caller.
محفوظة لهذه الجلسة على هذا المتصفح. راجعها بنفسك أو مع معلمك؛ لا يتم تصحيح هذه الشرح تلقائيًا.
راجع شرحك بناءً على معايير التقييم هذه
- My types and data structure match the data and the question.
- I justified the loop and checked its first and last iterations.
- Initial values and rejected operations preserve the intended state.
- My test includes input, purpose and expected result.
- I distinguished returning a value from printing and changing caller state.