📚 Programming Basics in IGCSE Computer Science | IGCSE 计算机:编程基础 考点精讲
In IGCSE Computer Science, mastering programming fundamentals is the key to success. This guide breaks down the core concepts every student must know, from algorithms to subroutines, with clear explanations and practical examples. Whether you are writing pseudocode or tracing flowcharts, understanding these building blocks will help you solve problems confidently in Paper 2 and beyond.
在 IGCSE 计算机课程中,掌握编程基础是成功的关键。本文拆解了每位学生必须掌握的核心概念——从算法到子程序,配以清晰的讲解和实用示例。无论你是写伪代码还是追踪流程图,理解这些构建模块都能帮助你在 Paper 2 及更远的考试中自信地解决问题。
1. Algorithms and Problem Solving | 算法与问题解决
An algorithm is a step-by-step sequence of instructions designed to perform a specific task or solve a problem. In computer science, algorithms must be precise, finite, and unambiguous, meaning each step is clearly defined and the process eventually ends. Common examples include sorting, searching, and mathematical calculations. When designing an algorithm, it is helpful to break the problem into smaller sub-problems, a technique known as decomposition. Identifying patterns and abstracting away unnecessary details are also important problem-solving skills tested in the IGCSE.
算法是为执行特定任务或解决问题而设计的一系列分步指令。在计算机科学中,算法必须精确、有限且无歧义,即每一步都有明确定义且过程最终会结束。常见例子包括排序、搜索和数学计算。设计算法时,将问题分解成更小的子问题(即分解技术)很有帮助。识别模式并抽象掉不必要的细节也是 IGCSE 考查的重要问题解决能力。
2. Pseudocode and Flowcharts | 伪代码与流程图
Pseudocode is a simplified, language-independent way to represent an algorithm using plain English and common programming keywords like INPUT, OUTPUT, IF, THEN, ELSE, FOR, WHILE. It is not executed by a computer but helps programmers plan logic before coding. In the IGCSE exam, you will be asked to read, write, and trace pseudocode. Flowcharts use standardized symbols: ovals for start/end, parallelograms for input/output, rectangles for processes, diamonds for decisions, and arrows to show the flow of control. Being able to convert between pseudocode and flowcharts is a crucial exam skill.
伪代码是一种简化的、与语言无关的表示算法的方式,使用简单的英语和常用编程关键字,如 INPUT、OUTPUT、IF、THEN、ELSE、FOR、WHILE。它不会被计算机执行,但帮助程序员在编程前规划逻辑。在 IGCSE 考试中,你会被要求阅读、编写和追踪伪代码。流程图使用标准化符号:椭圆表示开始/结束,平行四边形表示输入/输出,矩形表示过程,菱形表示判断,箭头表示控制流。能够在伪代码和流程图之间进行转换是重要的考试技能。
3. Variables and Data Types | 变量与数据类型
Variables are named storage locations in memory that hold data which can change during program execution. In IGCSE pseudocode, a variable is assigned a value using the left-pointing arrow or equals sign: Score ← 0 or Score = 0. Each variable has a data type that determines what kind of data it can store. The basic types include INTEGER (whole numbers), REAL (numbers with decimals, e.g., 3.14), CHAR (a single character like ‘A’), STRING (a sequence of characters like “Hello”), and BOOLEAN (TRUE or FALSE). Choosing appropriate data types is essential for memory efficiency and correct operations.
变量是内存中命名过的存储位置,存放着可以在程序执行期间改变的数据。在 IGCSE 伪代码中,使用向左箭头或等号给变量赋值:Score ← 0 或 Score = 0。每个变量都有数据类型,决定它能存储哪种数据。基本类型包括 INTEGER(整数)、REAL(带小数的实数,如 3.14)、CHAR(单个字符,如 ‘A’)、STRING(字符序列,如 “Hello”)和 BOOLEAN(TRUE 或 FALSE)。选择合适的数据类型对于内存效率和正确运算至关重要。
4. Basic Input and Output | 基本输入与输出
Programs communicate with the user or external devices through input and output statements. In pseudocode, INPUT reads data from the user (e.g., INPUT Name), and OUTPUT displays data or messages (e.g., OUTPUT “Result: “, Total). Input can be stored directly into a variable. When dealing with user prompts, it is common to combine an OUTPUT message to ask for input and then an INPUT command. For example: OUTPUT “Enter your age: ” INPUT Age. In flowcharts, the parallelogram represents both input and output operations.
程序通过输入和输出语句与用户或外部设备通信。在伪代码中,INPUT 读取用户数据(如 INPUT Name),OUTPUT 显示数据或消息(如 OUTPUT “Result: “, Total)。输入的内容可以直接存入变量。处理用户提示时,通常先用 OUTPUT 消息请求输入,再用 INPUT 命令。例如:OUTPUT “Enter your age: ” INPUT Age。流程图中,平行四边形同时表示输入和输出操作。
5. Arithmetic and Logical Operations | 算术与逻辑运算
Arithmetic operations involve standard mathematical calculations. In IGCSE pseudocode, operators are: + (addition), – (subtraction), * (multiplication), / (division), and ^ (exponentiation, e.g., 2^3 = 8). MOD gives the remainder after division (e.g., 10 MOD 3 = 1), and DIV gives the integer quotient (e.g., 10 DIV 3 = 3). Logical operators are used to combine boolean expressions: AND (both true), OR (at least one true), NOT (reverses truth value). Comparison operators include = (equal to), <> (not equal to), <, >, <=, >=. These operations form the backbone of decision making and calculations.
算术运算涉及标准的数学计算。在 IGCSE 伪代码中,运算符如下:+(加)、–(减)、*(乘)、/(除)、^(幂运算,如 2^3 = 8)。MOD 得到除法后的余数(如 10 MOD 3 = 1),DIV 得到整数商(如 10 DIV 3 = 3)。逻辑运算符用于组合布尔表达式:AND(两者皆真)、OR(至少一个为真)、NOT(反转真值)。比较运算符包括 =(等于)、<>(不等于)、<、>、<=、>=。这些运算构成了决策和计算的骨架。
6. Conditional Statements (IF…THEN…ELSE) | 条件语句
Conditional statements allow a program to make decisions and execute different code blocks based on whether a condition is true or false. The simplest form is IF…THEN…ENDIF. An extended version uses ELSE to handle the false case, and ELSE IF for multiple branches. In pseudocode:
IF Age >= 18 THEN
OUTPUT “Adult”
ELSE
OUTPUT “Minor”
ENDIF
Nested IF statements place one IF inside another, which is useful for complex logic but must be carefully structured. Common exam questions ask you to trace a conditional and predict the output for given input values.
条件语句允许程序做出决策,根据条件真假执行不同的代码块。最简单的形式是 IF…THEN…ENDIF。扩展版本使用 ELSE 处理假的情况,ELSE IF 用于多分支。在伪代码中,如上所示。嵌套 IF 语句把一个 IF 放在另一个里面,对复杂逻辑有用,但必须仔细结构化。常见考题是追踪条件语句,针对给定输入预测输出。
7. Loops (FOR, WHILE, REPEAT…UNTIL) | 循环结构
Loops repeat a block of code multiple times. Three types are used in IGCSE:
- FOR loop: repeats a fixed number of times, specified by a counter variable. FOR i ← 1 TO 10 runs 10 times.
- WHILE loop: repeats as long as a condition is true. The condition is checked at the start, so the loop might never run if the condition is initially false.
- REPEAT…UNTIL loop: executes at least once and then checks the condition at the end, looping until the condition becomes true.
Accumulators (e.g., Total ← Total + Value) and counters (Count ← Count + 1) are frequently used inside loops to aggregate data. Trace tables help track variable changes through each iteration.
循环重复执行一段代码多次。IGCSE 中使用三种类型:FOR 循环:按计数器变量指定固定次数,如 FOR i ← 1 TO 10 执行 10 次。WHILE 循环:条件为真时重复,条件在开头检查,若初始为假则循环可能一次都不执行。REPEAT…UNTIL 循环:至少执行一次,然后在末尾检查条件,直到条件为真时停止。累加器(如 Total ← Total + Value)和计数器(Count ← Count + 1)常在循环内使用以聚合数据。追踪表有助于跟踪每次迭代中变量的变化。
8. Arrays and Lists | 数组与列表
An array is a data structure that stores a fixed-size collection of elements of the same data type, accessed by an index. In pseudocode, arrays are declared like DECLARE Scores : ARRAY[1:5] OF INTEGER (a 1D array with indices 1 to 5). Elements are assigned and retrieved using brackets, e.g., Scores[3] ← 85. Lists, often used in higher-level programming, are more flexible and can grow dynamically. IGCSE primarily focuses on 1D arrays, but 2D arrays (matrices) are also introduced, using notation like Grid[Row, Column]. Understanding how to iterate through arrays using loops to find maximum, minimum, sum, or average is a tested skill.
数组是一种数据结构,存储固定大小的、相同数据类型元素的集合,通过索引访问。伪代码中,数组声明如 DECLARE Scores : ARRAY[1:5] OF INTEGER(一维数组,索引 1 到 5)。元素用方括号赋值和读取,如 Scores[3] ← 85。列表在高级编程中更灵活,可动态增长。IGCSE 主要聚焦一维数组,但也介绍二维数组(矩阵),使用符号 Grid[Row, Column]。理解如何使用循环遍历数组以求最大值、最小值、总和或平均值是需要掌握的技能。
9. String Manipulation | 字符串操作
Strings are sequences of characters, and IGCSE pseudocode includes several string-handling functions. LENGTH(Str) returns the number of characters. SUBSTRING(Str, Start, Length) extracts a part of the string, where the first character is at position 1. LEFT(Str, n) and RIGHT(Str, n) return the leftmost or rightmost n characters. Concatenation joins strings together using the & operator, e.g., FullName ← FirstName & ” ” & LastName. Converting between character codes is done with CHAR_CODE(Char : CHAR) and VALUE(Int). Typical exam tasks involve searching for a character, counting occurrences, or reversing a string.
字符串是字符序列,IGCSE 伪代码包含几种字符串处理函数。LENGTH(Str) 返回字符数。SUBSTRING(Str, Start, Length) 提取字符串的一部分,首字符位置为 1。LEFT(Str, n) 和 RIGHT(Str, n) 返回最左或最右的 n 个字符。使用 & 运算符进行拼接,如 FullName ← FirstName & ” ” & LastName。字符代码转换用 CHAR_CODE(Char : CHAR) 和 VALUE(Int)。典型考题涉及搜索某个字符、统计出现次数或反转字符串。
10. Subroutines, Functions and Procedures | 子程序、函数与过程
Subroutines break a program into named, reusable blocks of code. Procedures perform a task but do not return a value; they are defined with PROCEDURE Name(parameters) and called by CALL Name(args). Functions perform a task and return a single value using the RETURN statement. Parameters can be passed by value (a copy is used) or by reference (the original variable can be modified). Local variables exist only inside the subroutine, while global variables are accessible everywhere. Well-designed subroutines improve readability, reuse, and ease of debugging. Exam questions often ask you to write a function to calculate a value and integrate it into a larger program.
子程序将程序拆分成命名的、可复用的代码块。过程执行任务但不返回值,用 PROCEDURE Name(parameters) 定义,通过 CALL Name(args) 调用。函数执行任务并用 RETURN 语句返回单个值。参数可以按值传递(传递副本)或按引用传递(可以修改原始变量)。局部变量仅存在于子程序内部,而全局变量在所有地方都可访问。设计良好的子程序能提高可读性、复用性和调试便利性。考题经常要求你编写一个函数来计算某个值,并将其整合到更大的程序中。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导