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

IGCSE WJEC Computer Science: Programming Fundamentals | IGCSE WJEC 计算机科学:编程基础考点精讲

2026-07-14 01:07 · 本文部分内容由AI辅助创作

📚 IGCSE WJEC Computer Science: Programming Fundamentals | IGCSE WJEC 计算机科学:编程基础考点精讲

Programming is the core skill that turns algorithms into executable solutions. In the WJEC IGCSE Computer Science specification, you need to master fundamental concepts such as variables, sequence, selection, iteration, data structures and modular design. These concepts are assessed both in written theory papers and practical on-screen programming tasks. A solid understanding of pseudocode conventions, trace tables and debugging techniques will help you approach any question with confidence.

编程是将算法转化为可执行方案的核心技能。在 WJEC IGCSE 计算机科学大纲中,你需要掌握变量、顺序执行、选择、循环、数据结构以及模块化设计等基础概念。这些内容既会在理论笔试中考查,也会在机考编程题中应用。牢固掌握伪代码规范、跟踪表和调试技巧,能帮你从容应对各类考题。


1. Algorithms and Flowcharts | 算法与流程图

An algorithm is a step-by-step procedure designed to solve a specific problem. It must be precise, finite and unambiguous. Flowcharts provide a graphical representation of an algorithm using standard symbols: ovals for start/stop, parallelograms for input/output, rectangles for processes and diamonds for decisions. Arrows indicate the flow of control.

算法是为解决特定问题而设计的分步操作过程,必须具备精确性、有限性和无歧义性。流程图使用标准符号对算法进行图形化表示:椭圆表示开始/结束,平行四边形表示输入/输出,矩形表示处理过程,菱形表示判断。箭头指示控制流程方向。

A flowline without an arrowhead is not allowed in WJEC exams; every line must have an arrow to show direction. When tracing an algorithm, you follow the path determined by conditions. You can represent loops by directing flowlines back to an earlier step. The flowchart for a simple coffee machine might include a decision diamond checking if there are enough beans.

在 WJEC 考试中,流程线必须带有箭头以标明方向,不允许出现无箭头连线。跟踪算法时,你需要根据条件沿路径移动。你可以将流程线引回前面的步骤来表示循环。描绘简易咖啡机的流程图可能会包含一个菱形判断框,检测咖啡豆是否充足。


2. Variables and Data Types | 变量与数据类型

A variable is a named memory location that stores a value which can change during program execution. In pseudocode, we assign values using the ← symbol, for example score ← 0. Every variable has a data type that determines what operations can be performed on it. Common types include INTEGER, REAL (or FLOAT), BOOLEAN, CHAR and STRING.

变量是命名的内存位置,存储可在程序执行期间改变的值。在伪代码中,我们使用 ← 符号进行赋值,例如 score ← 0。每个变量都有数据类型,决定了可对其执行何种操作。常见类型包括 INTEGER(整型)、REAL/FLOAT(实型)、BOOLEAN(布尔型)、CHAR(字符型)和 STRING(字符串型)。

WJEC requires you to declare variables with their types before use, e.g. DECLARE name : STRING. Constants are similar but their value cannot be modified. Use meaningful identifiers following camelCase or underscores. Avoid reserved words like IF or WHILE as variable names.

WJEC 要求在使用变量前先声明其类型,例如 DECLARE name : STRING。常量与之类似,但其值不可更改。命名时应采用有意义的标识符,遵循驼峰命名法或下划线连接,并避免使用 IF、WHILE 等保留字作变量名。


3. Input and Output | 输入与输出

Programs interact with users through input and output operations. In WJEC pseudocode, OUTPUT displays a message or value, and INPUT reads data from the user into a variable. For instance: OUTPUT "Enter your age: " followed by INPUT age. The input always corresponds to the declared data type.

程序通过输入输出操作与用户交互。在 WJEC 伪代码中,OUTPUT 用于显示消息或值,INPUT 从用户读取数据并存入变量。例如 OUTPUT "Enter your age: " 后再执行 INPUT age。输入必须与变量声明的数据类型相匹配。

When writing on-screen code, you might use Python's input() function, which always returns a string, so casting with int() or float() is necessary. Always add prompts to guide the user, and format output with line breaks or tab spaces for readability.

在上机编程时,你可能会使用 Python 的 input() 函数,它始终返回字符串,因此需要通过 int() 或 float() 进行类型转换。务必添加提示信息引导用户,并利用换行或制表符美化输出格式,增强可读性。


4. Operators and Expressions | 运算符与表达式

Expressions combine values, variables and operators to produce a new value. Arithmetic operators include + (addition), - (subtraction), * (multiplication), / (division), MOD (modulus, remainder) and DIV (integer division). Comparison operators return Boolean results: =, ≠ (or <>), <, >, ≤, ≥. Logical operators AND, OR and NOT combine Boolean expressions.

表达式通过组合值、变量和运算符来产生新值。算术运算符包括 +(加)、-(减)、*(乘)、/(除)、MOD(求余)和 DIV(整除)。比较运算符返回布尔值:=、≠(或 <>)、<、>、≤、≥。逻辑运算符 AND、OR 和 NOT 用于组合布尔表达式。

Operator precedence in WJEC pseudocode follows standard mathematical rules: parentheses first, then NOT, followed by multiplication/division, then addition/subtraction, and finally relational and logical operators. Use brackets to make the order explicit and avoid logic errors. For example, (age ≥ 18) AND (member = TRUE).

WJEC 伪代码中的运算符优先级遵循标准数学规则:括号优先,其次 NOT,再次乘除,接着加减,最后是关系和逻辑运算符。建议使用括号明确运算顺序,避免逻辑错误。例如 (age ≥ 18) AND (member = TRUE)。


5. Selection (IF Statements) | 选择结构(条件语句)

Selection allows a program to make decisions. The basic structure is IF condition THEN ... ENDIF. The indented block executes only when the condition is true. An ELSE clause can provide an alternative path: IF ... THEN ... ELSE ... ENDIF. For multiple branches, use ELSE IF or CASE statements. Nested IFs embed one decision inside another.

选择结构使程序能够做出判断。基本结构为 IF condition THEN ... ENDIF,缩进的代码块仅在条件为真时执行。ELSE 子句提供另一条路径:IF ... THEN ... ELSE ... ENDIF。多分支可使用 ELSE IF 或 CASE 语句。嵌套 IF 则将判断嵌入另一个判断内。

In the WJEC pseudocode, a CASE structure is elegant when checking a single variable against several constant values. For example: CASE grade OF 'A': OUTPUT "Excellent"; 'B': OUTPUT "Good"; OTHERWISE OUTPUT "Keep trying" ENDCASE. Always ensure that conditions are exhaustive and mutually exclusive where needed.

在 WJEC 伪代码中,当需要检查某个变量是否等于多个常量值时,CASE 结构更加简洁。例如:CASE grade OF 'A': OUTPUT "Excellent"; 'B': OUTPUT "Good"; OTHERWISE OUTPUT "Keep trying" ENDCASE。始终确保条件覆盖所有可能,并在必要时保证互斥。


广告 / Sponsored

6. Iteration (Loops) | 循环结构

Iteration repeats a block of code. The three main types are: count-controlled FOR loop, condition-controlled WHILE loop and post-condition REPEAT...UNTIL loop. FOR i ← 1 TO 10 runs exactly ten times. WHILE x < 100 DO checks the condition at the start, and REPEAT...UNTIL x ≥ 100 checks at the end, so the body runs at least once.

循环结构重复执行某段代码。主要有三种类型:计数控制的 FOR 循环、条件控制的 WHILE 循环和后置条件的 REPEAT...UNTIL 循环。FOR i ← 1 TO 10 精确执行十次;WHILE x < 100 DO 在入口处检查条件;REPEAT...UNTIL x ≥ 100 在出口检查,因此循环体至少执行一次。

Use a FOR loop when the number of iterations is known beforehand. WHILE loops are ideal for reading data until a sentinel value is entered. Avoid infinite loops by ensuring the loop counter or condition variable is updated inside the loop body. WJEC questions often ask you to convert between loop types.

当循环次数预先已知时使用 FOR 循环。WHILE 循环适合读取数据直至出现哨兵值。通过在循环体内更新计数器或条件变量,避免出现无限循环。WJEC 试题常要求在不同循环类型之间进行转换。


7. Arrays (Lists) | 数组(列表)

An array is a data structure that stores multiple values of the same data type under a single identifier. Elements are accessed using an index, typically starting at 1 in WJEC pseudocode. Declaration: DECLARE scores : ARRAY[1:5] OF INTEGER. You can assign values with scores[3] ← 87. 2D arrays are declared as ARRAY[1:3, 1:4].

数组是一种数据结构,可在单个标识符下存储多个同类型的值。通过索引访问元素,WJEC 伪代码中索引通常从 1 开始。声明格式:DECLARE scores : ARRAY[1:5] OF INTEGER。可通过 scores[3] ← 87 赋值。二维数组声明为 ARRAY[1:3, 1:4]。

Traversing an array safely requires knowing its bounds. Use a FOR loop: FOR i ← 1 TO LENGTH(scores). Common algorithms include linear search, finding maximum/minimum and calculating an average. Always initialise aggregate variables before the loop, e.g. total ← 0.

安全遍历数组需了解其边界,结合 FOR 循环:FOR i ← 1 TO LENGTH(scores)。常见算法包括线性搜索、寻找最大值/最小值以及计算平均值。务必在循环之前初始化累计变量,例如 total ← 0。


8. String Manipulation | 字符串操作

Strings are sequences of characters. WJEC pseudocode provides functions like LEN(str) to get the length, LEFT(str, n) to extract the leftmost n characters, RIGHT(str, n) and MID(str, start, n). Concatenation uses the + operator or & symbol. Converting case might involve UPPER(str) and LOWER(str).

字符串是字符序列。WJEC 伪代码提供 LEN(str) 获取长度,LEFT(str, n) 提取最左边 n 个字符,RIGHT(str, n) 和 MID(str, start, n) 提取子串。拼接使用 + 或 & 符号。大小写转换可用 UPPER(str) 和 LOWER(str)。

Typical exam tasks include extracting initials, checking if a string is a palindrome, or formatting names. Remember that string indexing starts at 1 for the first character. When comparing strings, lexicographical order is used, so 'A' < 'B', and digits '0' to '9' are ordered before letters in ASCII.

典型考题包括提取首字母缩写、检查字符串是否为回文或格式化姓名。注意字符串索引从 1 开始,第一个字符的位置为 1。字符串比较按照字典顺序进行,因此 'A' < 'B',且在 ASCII 中数字 '0' 至 '9' 排在字母之前。


9. Subroutines and Functions | 子程序与函数

Subroutines are named blocks of code that perform a specific task. Procedures do not return a value and are defined using PROCEDURE. Functions return a single value and are defined with FUNCTION and terminated by RETURN . Parameters allow data to be passed; they can be passed by value or by reference (using BYREF).

子程序是执行特定任务的有名代码块。过程不返回值,使用 PROCEDURE 定义。函数返回一个值,用 FUNCTION 定义并以 RETURN <值> 结束。参数用于传递数据,可以按值传递或按引用传递(使用 BYREF)。

Modular programming makes code easier to understand, test and reuse. In WJEC pseudocode you must call a procedure with CALL ProcedureName(arg1, arg2), while functions are used within expressions, e.g. result ← CalculateTax(income). Local variables inside subroutines are inaccessible outside.

模块化编程使代码更易理解、测试和复用。在 WJEC 伪代码中,调用过程须使用 CALL ProcedureName(arg1, arg2),函数则在表达式中使用,如 result ← CalculateTax(income)。子程序内部的局部变量在外部不可见。


10. Pseudocode Conventions (WJEC) | 伪代码规范

WJEC expects candidates to follow a consistent pseudocode style. Key rules include: use ← for assignment, = for comparison; indent blocks under IF, WHILE and FOR; clearly mark ENDIF, ENDWHILE, NEXT or ENDFOR. Comments start with //. Input and output are INPUT and OUTPUT.

WJEC 要求考生遵循统一的伪代码风格。关键规则包括:使用 ← 赋值,= 比较;在 IF、WHILE 和 FOR 下缩进代码块;明确标记 ENDIF、ENDWHILE、NEXT 或 ENDFOR。注释以 // 开头。输入输出使用 INPUT 和 OUTPUT。

You may be asked to write pseudocode for a given problem. Use meaningful names, keep lines short, and walk through your logic with sample data. Avoid language-specific syntax like Python's colon or JavaScript's braces. The examiner must be able to follow the flow without ambiguity.

你可能会被要求针对特定问题编写伪代码。应使用有意义的名称,保持每行简短,并用样例数据走查逻辑。避免使用特定语言语法,如 Python 的冒号或 JavaScript 的花括号。阅卷人必须能够无歧义地理解代码流程。


11. Trace Tables | 跟踪表

A trace table is a systematic tool for testing algorithms by hand. You create columns for each variable, condition and output. Row by row, you record how values change as each line of pseudocode executes. This technique helps identify logical errors and is frequently assessed in WJEC papers.

跟踪表是一种手工测试算法的系统化工具。你为每个变量、条件和输出建立列,逐行记录伪代码执行时值的变化。这一技巧有助于发现逻辑错误,在 WJEC 试卷中经常考查。

When completing a trace table, update only the variable that changes. For loops, note the loop counter and test conditions carefully. If an IF condition is false, leave the associated output blank. The final row should show the program's output values. Practice with nested loops and array access to build speed.

填写跟踪表时,仅更新发生变化的变量。涉及循环时,仔细记录循环计数器和测试条件。如果 IF 条件为假,对应输出留空。最后一行应展示程序的输出值。多加练习嵌套循环和数组访问,以提高解题速度。


12. Common Programming Errors and Debugging | 常见编程错误与调试

Syntax errors occur when code breaks the language rules, such as missing punctuation or misspelled keywords. Logic errors produce unexpected results even though the code runs. Runtime errors happen during execution, e.g. division by zero or array index out of bounds. Thorough testing with normal, boundary and exceptional data is essential.

语法错误指代码违反语言规则,例如缺少标点或拼错关键字。逻辑错误即使在代码运行时也会产生非预期结果。运行时错误在执行过程中出现,如除零或数组索引越界。使用正常、边界和异常数据进行彻底测试至关重要。

Debugging techniques include using trace tables, inserting temporary OUTPUT statements to inspect values, and stepping through code line by line. In an exam, you might be shown a flawed algorithm and asked to identify and correct the error. Read carefully and simulate the code mentally.

调试技巧包括使用跟踪表、插入临时的 OUTPUT 语句检查变量值,以及逐行步进代码。考试中可能会给出一个有缺陷的算法,要求你识别并纠正错误。务必仔细阅读并在脑中模拟执行。


Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

更多咨询请联系16621398022(同微信)

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