← 返回资讯屏轩教育 · 行业资讯

AQA编程 数据类型 循环 数组 子程序 校验 | AQA Programming: Data Types, Loops, Arrays, Subroutines, Validation

2026-10-21 04:03 · 本文部分内容由AI辅助创作

AQA编程 数据类型 循环 数组 子程序 校验

AQA 在 2025 年 6 月发布了 GCSE Computer Science 8525 的 1.3 版 specification,2025 年 9 月首次教学,2027 年夏季首考。新版卷面里 Paper 1 是两小时、90 分、占 50%,考查范围是 3.1 Fundamentals of algorithms 与 3.2 Programming。Paper 2 是一小时四十五分、90 分、占 50%,考 3.3 到 3.8 的内容。编程题全部写在纸上,考生用 C#、Python 3 或 VB.NET 中的一种作答,不需要打开电脑。下面按 specification 的 3.2 小节往前推进,把编程部分真正会出现在卷面上的知识点逐条拆开。

AQA's revised GCSE Computer Science specification (8525, version 1.3, June 2025) is taught from September 2025 and examined for the first time in summer 2027. Paper 1 lasts two hours, carries 90 marks and draws only on sections 3.1 and 3.2; Paper 2 runs for one hour and forty-five minutes, is worth the other half of the qualification and tests sections 3.3 to 3.8. Every programming answer is handwritten in C#, Python 3 or VB.NET, so what is being marked is the quality of the logic rather than typing speed. What follows works through the programming content in specification order, using the wording examiners reward.

数据类型、变量与常量

规范里的 3.2.1 要求你分清五种数据类型:integer、real、Boolean、character 和 string,并且能在一个程序里挑对类型。整数用来计数,real 用来存带小数的量,Boolean 只有真与假两种取值,character 是单个字符,string 是一串字符。很多学生以为 real 和 integer 只是写法差别,实际上 7/2 在整数类型下会把小数部分丢掉。变量要先声明再赋值,常量一旦赋值就不该在程序里改动。阅卷时经常看到把税率、最大尝试次数这类固定值写成变量,题目问为什么用常量时就答不出重点。常量让程序更易读,也让修改只发生在一个地方。变量名要有意义,totalScore 比 t 更能让阅卷人看懂逻辑。

Five data types are named in 3.2.1, namely integer, real, Boolean, character and string, and the paper expects a sensible choice for each job. Whole counts belong in integers, measurements with a fractional part belong in real, Boolean is limited to true and false, a character holds one symbol and a string holds a run of them. A common mistake is treating integer and real as interchangeable, since 7/2 truncates under integer division and quietly loses the remainder. Named constants exist so a value such as a tax rate or a maximum number of attempts is written once and read everywhere; that is exactly the point examiners want when they ask why a constant was used rather than a variable.

选择结构、嵌套选择与区间覆盖

规范里的 3.2.2 把选择结构与顺序结构、迭代并列,作为写程序时最基本的三种组合方式。单分支写成 IF ... THEN ... ENDIF,双分支加 ELSE,多分支用 ELSEIF 串起来,也可以按语言习惯写成 case 或 switch。嵌套选择指的是一个 IF 里面再放一个 IF,缩进能帮你确认哪一个 ENDIF 与哪一个 IF 配对。常见的错误是漏掉某个取值区间,比如分数在 60 到 69 之间的分支被两边的条件挤掉。写多分支时先把所有可能的区间列在纸上,再按从大到小或从小到大排好,能避免条件重叠与留空。阅卷时看的是每一种输入是否都能走到一个明确的输出,而不是分支写得多漂亮。

Selection sits with sequence and iteration as one of the three ways statements are combined inside a program. A single branch uses IF ... THEN ... ENDIF, a two-way branch adds ELSE, and a chain of ELSEIF handles more than two cases; nested selection simply places one IF inside another, which is why indentation matters when you pair ENDIFs. Many students lose marks by leaving a gap between ranges, so a score of 65 falls through every condition; listing the intervals before writing any code prevents both overlap and omission. Examiners follow each possible input through to a clear output rather than admiring the layout.

计数循环与条件循环

计数循环用 FOR ... NEXT 或 FOR ... ENDFOR,循环次数在进入循环之前就已经确定。条件循环分两种:条件写在开头用 WHILE,条件写在结尾用 REPEAT ... UNTIL 或 DO ... WHILE。很多学生以为两种条件循环可以随便换,实际上条件在结尾的结构至少会执行一次循环体,这一点在输入校验题里直接影响答案。嵌套循环要注意内外层的循环变量不能同名,否则内层会把外层的计数改掉。规范里的 3.2.2 还要求你读懂条件在两端的写法,即使你用的语言只支持其中一种。写循环前先想清楚终止条件会不会被满足,否则程序运行时会一直转下去。

Count-controlled iteration runs a fixed number of times, so a FOR loop fits when the repeat count is known before the loop starts. Condition-controlled iteration comes in two shapes: WHILE tests at the top, while REPEAT ... UNTIL and DO ... WHILE test at the bottom. The bottom-tested form always executes its body at least once, which is why validation routines lean on it and why swapping the two shapes changes the answer. Nested loops need distinct counter names, since reusing one variable silently overwrites the outer count, and every loop needs a terminating condition that the body can actually reach.

整数除法、取余与位数拆分

规范里的 3.2.3 只列了加减乘、实数除法,以及带余数的整数除法,而最后这一项是 Paper 1 的高频考点。AQA 的 specification 给了明确例子:11 DIV 2 得 5,11 MOD 2 得 1,两步合起来才是完整的整数除法结果。用 MOD 10 可以取到一个整数的最后一位,用 DIV 10 可以把它去掉,重复这两步就能逐位处理一个数。判断奇偶只需看 n MOD 2 是否等于 0,判断整除同理。很多学生以为 DIV 和 MOD 只是写法不同,其实一个给商一个给余数,写错就会让循环少走一轮。进位制转换、找零、数字反转这几类题都靠这两个运算。

Section 3.2.3 lists addition, subtraction, multiplication, real division and integer division with remainders, and the last of these carries most of the marks. AQA's own example is explicit: 11 DIV 2 gives 5 and 11 MOD 2 gives 1, and a full description of the division needs both values. Taking a number MOD 10 isolates its last digit while DIV 10 removes it, so repeating the pair walks through every digit, and testing n MOD 2 for zero is the standard parity check. Treating DIV and MOD as cosmetic variants produces loops that run one time too few.

关系运算与布尔运算的组合

关系运算有等于、不等于、小于、大于、小于等于和大于等于六种,不同语言用的符号不完全一样,答题时按题目给出的形式写就好。布尔运算只有 NOT、AND、OR 三个,优先级上 NOT 最高,AND 次之,OR 最低,不确定时加括号最稳。常见的错误是拿赋值符号当等于号,在条件里写错一个符号,整个分支就永远不成立。把范围判断拆成两个关系再用 AND 连起来,比写成一个数学式更符合规范答案。NOT 用在否定条件上能让代码更短,但连用两个 NOT 只会让自己看不懂。写条件时先念一遍中文意思,再落成符号,能挡掉大部分逻辑错误。

Relational operators cover equal to, not equal to, less than, greater than and the two inclusive forms, and the symbols differ between languages, so follow whatever notation the question uses. Boolean operators are limited to NOT, AND and OR, with NOT binding tightest and OR loosest, and brackets remove all doubt about the order. Writing an assignment where a comparison belongs is the error that keeps appearing in scripts, and it silently makes a branch unreachable. A range is safest expressed as two comparisons joined by AND, while a doubled NOT usually costs clarity instead of saving space.

一维数组、二维数组与记录

规范里的 3.2.6 只要求一维和二维数组,记录也只是简单结构,但索引方式的差异是常见丢分点。一维数组存一列同类数据,二维数组可以想成表格,用两个下标定位行列。不同语言的下标起点不同,AQA 的伪代码默认从 1 开始,Python 从 0 开始,答题时按题目给的伪代码或你选的语言来。遍历数组要用循环配合下标,长度不要写死,否则改动数据量就要重写。记录把不同类型但同属一个对象的数据捆在一起,specification 举的例子是 Car,里面有 make、model、reg、price 与门数。常见的错误是把记录当成数组用,然后按位置取值,读起来完全没有意义。

Only one- and two-dimensional arrays are required, together with simple records, yet indexing is where marks disappear. An array stores a list of values of one type, a two-dimensional array behaves like a table addressed by row and column, and a record groups fields of different types that describe one object, such as the Car example with make, model, reg, price and number of doors. Lower bounds differ between AQA pseudo-code, which starts at 1, and Python, which starts at 0, so follow the notation given in the question. Loops should run to the array length rather than a hard-coded number, and fields should be read by name so the logic stays readable.

字符串处理与类型转换

规范里的 3.2.8 列出 length、position、substring、concatenation、字符与字符编码互转,以及字符串与数值之间的转换。length 给长度,position 找子串出现的位置,substring 按起止位置截取,concatenation 把两段接成一段。字符转编码用类似 ASC 的函数,编码转字符用 CHR,题目常借此考查大写与小写的编码差值。字符串转整数、转实数要显式转换,直接把读到的输入拿来做加法会变成拼接。常见的错误是把从键盘读到的内容当数字用,结果 3 加 4 得到 34。写校验时先转换再比较,顺序反了会直接抛错。

String handling covers length, position, substring, concatenation, character-to-code and code-to-character conversion, plus conversions between strings and numbers. Length returns how many characters a string holds, position locates a substring, substring cuts between two positions, concatenation joins pieces end to end, and ASC and CHR move between a character and its code, which is how case differences are usually tested. Input read from the keyboard arrives as a string, so it must be converted before arithmetic, otherwise 3 plus 4 produces 34. Convert first and compare afterwards, since reversing the order raises an error instead of giving a wrong answer.

子程序、参数传递与局部变量

规范里的 3.2.10 把子程序定义为一个命名的、独立的代码块,写它的名字就能调用。参数负责把数据送进子程序,返回值负责把结果送出来,specification 说明可考材料里统一用 parameter 这个词,不再区分 argument。子程序可以声明自己的局部变量,这类变量只在子程序执行期间存在,也只能在内部访问。用局部变量能避免不同子程序互相改掉对方的计数变量,这是结构化编程的核心好处之一。很多学生以为子程序只是让代码变短,其实它固定了输入输出的接口,让测试可以逐个模块做。结构化方法还要求接口有清楚文档,参数与返回值写明白,别人不用读完全部代码就能调用。

Section 3.2.10 defines a subroutine as a named block of code sitting outside the main flow and executed by writing its name. Parameters carry data in and return values carry results out, and the specification uses parameter for both arguments and parameters in examinable material. A subroutine can declare local variables that exist only while it runs and are visible only inside it, which stops one routine from overwriting another's counter; that isolation is one of the main advantages of the structured approach. The other is a documented interface, so a module can be tested and reused without reading its internals.

随机数生成与模拟题

规范里的 3.2.9 只要求会用随机数生成,不要求理解伪随机数的内部算法,这一点写得很清楚。常见写法是 RANDOM_INT(1, 6) 这类区间调用,得到的就是闭区间内的整数。模拟掷骰子、抽题、洗牌都靠它,骰子那一类题通常还要统计每个点数出现的次数。常见的错误是把随机数当成每次都不一样,同一轮程序里连调两次,得到的可能是同一个值,需要先存进变量再复用。范围写错也很常见,想要 1 到 6 却写成 0 到 6,统计结果就会多出一个不可能的点数。题目要求用随机数时,答案里要真的出现这个调用,用固定值代替会直接丢分。

Random number generation is required at the level of use only, and the specification states that how pseudo-random values are produced is not examinable. A call such as RANDOM_INT(1, 6) returns an integer inside the stated range, which is enough to simulate a die, pick a question or shuffle a list, and dice questions usually add a tally of how often each face appears. Store the value in a variable when it is needed twice, because a second call is not guaranteed to repeat the first. Watch the bounds as well, since 0 to 6 produces a face that cannot exist, and a fixed number where a random call was demanded scores nothing.

数据校验与简单认证

规范里的 3.2.11 要求能写简单的数据校验,specification 举了三类检查:字符串最小长度、字符串是否为空、数值是否落在给定区间。校验一般放在循环里,不满足就重新输入,条件写在结尾的循环在这里最好用。认证只考用户名与密码的明文比对,不需要加密,题目也不会要求你处理哈希。常见的错误是把校验写成一次性的 IF,用户输错就直接结束程序,而题目要的是允许重试。另一个错误是把范围判断写成开区间,1 到 10 的题把 1 和 10 判成非法。写这类题时把提示语、读取、判断、重试四步顺着写下来,逻辑就不会乱。

Validation routines in 3.2.11 are limited to a few checks: minimum length, an empty string, and a value inside a stated range. They usually sit inside a loop that repeats until the input is acceptable, which is the natural home for a bottom-tested loop. Authentication is plain-text comparison of a stored username and password, with no encryption expected at this level. A single IF that ends the program on bad input fails the question, and an open range that rejects 1 and 10 fails it too; prompt, read, test and repeat is the order that keeps the logic sound.

测试数据与语法逻辑错误

规范里的 3.2.11 还要求你说明三类测试数据:normal、boundary 与 erroneous。specification 给了边界的判定方法,允许范围是 1 到 10 时,0、1、10、11 都算边界数据,因为它们在边界的两侧。正常数据落在区间内部,错误数据则是类型不对或明显不合理的输入,比如年龄填 -5 或姓名填数字。错误类型只分语法错误与逻辑错误两种,语法错误让程序根本跑不起来,逻辑错误能跑但结果不对。用追踪表逐行记录变量取值,是判断逻辑错误最快的办法。阅卷时看到只写一组测试数据的答案,通常只能拿一半分。

Three kinds of test data are examinable: normal, boundary and erroneous. The specification's own rule for boundary values is that a permitted range of 1 to 10 makes 0, 1, 10 and 11 boundary data, since they sit either side of the limits, while normal data falls inside the range and erroneous data has the wrong type or an impossible value such as an age of -5. Errors are classed as syntax errors, which stop the program running, or logic errors, which run but give the wrong result. A trace table showing each variable line by line is the quickest way to catch the second kind, and a single test case rarely earns full marks.

查找与排序的时间效率比较

规范里的 3.1 直接进 Paper 1,其中查找与排序的比较题几乎每次考试都出现。线性查找从头到尾逐个比较,数据没有排序也能用,最坏情况要看完整个列表。二分查找要求列表先排好序,每次砍掉一半,数据量大时优势明显。冒泡排序反复比较相邻两项并交换,轮数多但过程容易追踪;归并排序把列表不断对半拆开再合并,比较次数少但需要额外空间。specification 说明正式的时间复杂度比较不作要求,题目只问效率高低与原因。常见的错误是只答二分查找更快,不写前提是有序,分数就丢在这里。

Searching and sorting comparisons sit in section 3.1 and appear in Paper 1 almost every series. Linear search compares items one by one and works on unsorted data, but may have to inspect the whole list, whereas binary search halves the search space each time and only works once the data is sorted. Bubble sort repeatedly swaps adjacent items, which is slow on large lists yet easy to trace, while merge sort splits, sorts and merges, using fewer comparisons at the cost of extra memory. The specification asks only for time efficiency rather than formal complexity, and the mark for binary search depends on naming the sorted precondition.

戴睿(dere)Neo优选系列 创意双触摸屏高性能笔记本电脑大学生AI学习商务办公设计炒股娱乐手提轻薄本32/1TB¥4586.0📱 去京东购买京东精选

广告 / Sponsored
商品图片
【学为贵官方店】学为贵刘洪波 A-Level核心词汇真经五件套 alevel教材 alevel生物 化学 经济 数学 …
¥123.9
到手价 · 以淘宝页面为准
生物、物理 备考教辅 · 正版现货 · 学习备考通用
查看详情 / View on Taobao
广告 / Sponsored
商品图片
Oxford 剑桥CIE考试局 AS A level Exam Success Guide 牛津出版国际备考系列 英文…
¥233
到手价 · 以淘宝页面为准
地理、生物 备考教辅 · 正版现货 · 学习备考通用
查看详情 / View on Taobao
更多咨询请联系16621398022(同微信)

需要一对一辅导?Need One-on-One Tutoring?

A-Level / GCSE / IB / KS2-KS3 全科辅导,编程与计算机科学同样覆盖

16621398022 同微信

Visit aleveler.com
备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao