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

Programming Fundamentals for IGCSE Computer Science | IGCSE计算机科学编程基础

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

📚 Programming Fundamentals for IGCSE Computer Science | IGCSE计算机科学编程基础

Programming is at the heart of computer science. It allows us to give precise instructions to computers so that they can solve problems, process data, and control devices. For Cambridge IGCSE Computer Science, understanding the fundamentals of programming is essential – not just learning a specific language, but grasping the logical thinking behind algorithms, pseudocode, and structured code. This article covers the key concepts you need to master for the programming paper, from variables to file handling, with clear examples in Cambridge IGCSE pseudocode.

编程是计算机科学的核心。它使我们能够向计算机发出精确的指令,让计算机解决问题、处理数据并控制设备。对于剑桥 IGCSE 计算机科学来说,理解编程基础至关重要——不仅要学习某种特定语言,还要掌握算法、伪代码和结构化代码背后的逻辑思维。本文涵盖你在编程试卷中需要掌握的关键概念,从变量到文件处理,均配有剑桥 IGCSE 伪代码的清晰示例。


1. What Is Programming? | 什么是编程?

Programming is the process of designing and writing a sequence of instructions (code) that a computer can execute to carry out a specific task.

编程是设计并编写一系列指令(代码)的过程,计算机可以执行这些指令来完成特定任务。

In IGCSE, you are not required to write code in a real programming language such as Python or Java. Instead, you will use a standard pseudocode that clearly expresses the logic of your solution.

在 IGCSE 中,不要求你用 Python 或 Java 等真实的编程语言编写代码,而是使用一种标准的伪代码,清楚地表达你解题的逻辑。

The purpose of programming is to solve problems. A programmer must first understand the problem, design an algorithm, and then implement it in code.

编程的目的是解决问题。程序员必须首先理解问题、设计算法,然后用代码实现它。


2. Algorithms and Problem Solving | 算法与问题解决

An algorithm is a step-by-step procedure for solving a problem. It is independent of any programming language and can be described in English, as a flowchart, or in pseudocode.

算法是解决问题的分步过程。它独立于任何编程语言,可以用英语、流程图或伪代码来描述。

Good algorithms have three important properties: they are clear and unambiguous, they terminate (stop after a finite number of steps), and they produce correct output for all valid inputs.

好的算法有三个重要特性:清晰明确、会终止(在有限步骤后停止)、对所有有效输入都能产生正确输出。

Before writing code, you should decompose the problem into smaller parts. This technique is called 'divide and conquer' and makes complex tasks easier to manage.

在编写代码之前,你应该把问题分解成更小的部分。这种技术叫做“分而治之”,能让复杂的任务更容易处理。


3. Pseudocode and Flowcharts | 伪代码与流程图

Pseudocode is a simplified, language-independent way of writing algorithms. The Cambridge IGCSE pseudocode uses key words like INPUT, OUTPUT, IF ... THEN ... ELSE ... ENDIF, and loops like FOR ... TO ... NEXT.

伪代码是一种简化的、与语言无关的算法书写方式。剑桥 IGCSE 伪代码使用 INPUT、OUTPUT、IF ... THEN ... ELSE ... ENDIF 等关键字,以及 FOR ... TO ... NEXT 这样的循环结构。

Flowcharts are graphical representations of algorithms. A rectangle represents a process, a diamond shows a decision, a parallelogram is used for input/output, and arrows indicate the flow of control.

流程图是算法的图形化表示。矩形表示处理步骤,菱形表示判断,平行四边形用于输入/输出,箭头表示流程的方向。

Both tools help you plan programs before coding. In exams, you may be asked to trace a flowchart or write pseudocode from a description.

这两种工具都能帮助你在编码前规划程序。在考试中,你可能会被要求跟踪流程图或根据描述写出伪代码。


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

A variable is a named storage location in memory that holds a value which can change during program execution.

变量是内存中有名称的存储位置,它保存的值在程序执行过程中可以改变。

Each variable has a data type that tells the computer what kind of data it holds. The main types are INTEGER (whole numbers), REAL (numbers with decimal points), CHAR (a single character), STRING (a sequence of characters), and BOOLEAN (TRUE or FALSE).

每个变量都有一个数据类型,它告诉计算机所保存的数据属于哪一类。主要类型有 INTEGER(整数)、REAL(带小数点的数)、CHAR(单个字符)、STRING(字符序列)和 BOOLEAN(TRUE 或 FALSE)。

In pseudocode, you declare variables using the DECLARE statement, for example: DECLARE Score : INTEGER. You should always choose meaningful variable names like 'TotalMarks' rather than 'x'.

在伪代码中,你用 DECLARE 语句声明变量,例如:DECLARE Score : INTEGER。应该始终选择有意义的变量名,如 'TotalMarks',而不是 'x'。


5. Constants, Input and Output | 常量、输入与输出

A constant is similar to a variable, but its value cannot be changed while the program is running. Use constants for fixed values like the value of π (3.142) or a tax rate.

常量与变量相似,但在程序运行过程中其值不能改变。对于像 π 的值 (3.142) 或税率这样的固定值,应使用常量。

Input allows the program to receive data from the user or an external source. In pseudocode, you use INPUT VariableName to store the user's entry.

输入让程序能够从用户或外部源接收数据。在伪代码中,你使用 INPUT VariableName 来存储用户的输入。

Output sends data from the program to the screen, printer or a file. The command OUTPUT "Hello" displays the message. You can also output the value of a variable: OUTPUT Score.

输出将数据从程序发送到屏幕、打印机或文件。命令 OUTPUT "Hello" 会显示这条消息。你也可以输出变量的值:OUTPUT Score。


6. Sequence, Selection, and Iteration | 顺序、选择和迭代

All programs are built from three control structures: sequence, selection, and iteration. Sequence means instructions are executed one after the other in order.

所有程序都由三种控制结构构建而成:顺序、选择和迭代。顺序是指指令按次序一条接一条地执行。

Selection allows the program to choose different paths based on a condition. The IF ... THEN ... ELSE ... ENDIF structure is used. For example:

选择使程序能够根据条件选择不同的路径。使用 IF ... THEN ... ELSE ... ENDIF 结构。例如:

IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Minor" ENDIF

Iteration repeats a block of code. There are count-controlled loops (FOR ... TO ... NEXT) and condition-controlled loops (WHILE ... DO ... ENDWHILE, REPEAT ... UNTIL).

迭代重复执行一段代码。有计数控制循环(FOR ... TO ... NEXT)和条件控制循环(WHILE ... DO ... ENDWHILE、REPEAT ... UNTIL)。

A FOR loop runs a fixed number of times: FOR i ← 1 TO 10 ... NEXT i. A WHILE loop continues as long as the condition is true: WHILE Num > 0 DO ... ENDWHILE.

FOR 循环运行固定次数:FOR i ← 1 TO 10 ... NEXT i。WHILE 循环只要条件为真就继续执行:WHILE Num > 0 DO ... ENDWHILE。


广告 / Sponsored

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

Operators are symbols that perform operations on data. Arithmetic operators include + (addition), - (subtraction), * (multiplication), / (division), and MOD (modulus, the remainder after division).

运算符是对数据执行操作的符号。算术运算符包括 +(加)、-(减)、*(乘)、/(除)和 MOD(取模,即除法后的余数)。

lean result: = (equal to), <> (not equal to), > (greater than), < (less than), >=, and <=.

比较运算符比较值并返回布尔结果:= (等于)、<> (不等于)、> (大于)、< (小于)、>= (大于等于)和 <= (小于等于)。

Logical operators combine Boolean conditions: AND, OR, and NOT. For example, IF Score > 50 AND Score <= 100 THEN ...

逻辑运算符组合布尔条件:AND、OR 和 NOT。例如,IF Score > 50 AND Score <= 100 THEN ...

Expressions are combinations of values, variables and operators that evaluate to a single result. Total ← Price * Quantity is an expression that multiplies two variables.

表达式是值、变量和运算符的组合,会计算出单个结果。Total ← Price * Quantity 就是一个将两个变量相乘的表达式。


8. Arrays (One-Dimensional) | 一维数组

An array is a data structure that stores a collection of elements of the same data type under a single name. Each element can be accessed using an index, which typically starts at 1 in Cambridge pseudocode.

数组是一种数据结构,它在单个名称下存储一组相同数据类型的元素。每个元素可以通过索引访问,在剑桥伪代码中索引通常从 1 开始。

You declare an array with DECLARE Names : ARRAY[1:30] OF STRING. This creates a list of 30 strings named 'Names'.

你可以用 DECLARE Names : ARRAY[1:30] OF STRING 声明一个数组。这会创建一个包含 30 个字符串的列表,名称为 'Names'。

Assign values with Names[5] ← "Alice". A common use is to iterate through an array with a FOR loop: FOR i ← 1 TO 30 ... OUTPUT Names[i] ... NEXT i.

用 Names[5] ← "Alice" 给数组赋值。常见的用法是用 FOR 循环遍历数组:FOR i ← 1 TO 30 ... OUTPUT Names[i] ... NEXT i。


9. Procedures and Functions | 过程与函数

Procedures and functions allow you to break a program into smaller, reusable parts. A procedure performs a task but does not return a value. You define it with PROCEDURE Name(Parameters) ... ENDPROCEDURE.

过程和函数让你能够把程序分解成更小、可重复使用的部分。过程执行一项任务但不返回值。你用 PROCEDURE Name(Parameters) ... ENDPROCEDURE 来定义它。

A function also performs a task but always returns a single value. Its definition starts with FUNCTION Name(Parameters) RETURNS DataType and ends with ENDFUNCTION. Inside the function, you use RETURN value.

函数同样执行任务,但总会返回一个值。其定义以 FUNCTION Name(Parameters) RETURNS DataType 开始,以 ENDFUNCTION 结束。在函数内部,你使用 RETURN value。

Parameters pass data into procedures and functions. This makes code more flexible and avoids repeating almost identical code blocks.

参数将数据传递给过程和函数。这使代码更灵活,并避免重复几乎相同的代码块。


10. File Handling | 文件处理

Programs often need to read from or write to text files. In Cambridge pseudocode, you open a file with OPENFILE FileName FOR READ or OPENFILE FileName FOR WRITE.

程序经常需要读取或写入文本文件。在剑桥伪代码中,你用 OPENFILE FileName FOR READ 或 OPENFILE FileName FOR WRITE 打开文件。

To read a line of text, use READFILE FileName, LineVariable. After reading, you should close the file with CLOSEFILE FileName.

要读取一行文本,使用 READFILE FileName, LineVariable。读取后,应该用 CLOSEFILE FileName 关闭文件。

When writing, you use WRITEFILE FileName, Data. This appends data to the end of the file. Always close the file to ensure the data is saved properly.

写入时,你使用 WRITEFILE FileName, Data。这会将数据追加到文件末尾。总得关闭文件以确保数据被正确保存。


11. Testing and Debugging | 测试与调试

Testing is the process of checking whether a program works correctly. You should use normal data (valid, expected input), boundary data (edge cases), and erroneous data (invalid inputs) to thoroughly test your code.

测试是检查程序是否正常工作的过程。你应该使用正常数据(有效、预期的输入)、边界数据(边缘情况)和错误数据(无效输入)来全面测试你的代码。

Debugging is finding and fixing errors. There are three main types: syntax errors (typos in keywords), logic errors (the program runs but gives wrong results), and runtime errors (problems that occur during execution, like dividing by zero).

调试是查找并修正错误的过程。主要有三类错误:语法错误(关键字拼写错误)、逻辑错误(程序能运行但给出错误结果)和运行时错误(执行过程中发生的问题,如除以零)。

A trace table is a useful tool for debugging. You track the values of variables step by step through the code to see where the logic goes wrong.

跟踪表是调试的有用工具。你逐步跟踪代码执行过程中变量的值,看看逻辑在哪里出错。


12. Programming Best Practices | 编程最佳实践

Good programming is not just about making the code work; it should also be readable, maintainable, and efficient. Use meaningful identifiers, add comments to explain tricky parts, and keep the layout clean with proper indentation.

优秀的编程不仅在于让代码能够运行,代码还应具备可读性、可维护性和高效性。使用有意义的标识符,添加注释以解释复杂部分,并通过恰当的缩进保持布局清晰。

In IGCSE pseudocode, you can add comments by writing // This is a comment. The computer ignores everything after // on that line.

在 IGCSE 伪代码中,你可以通过书写 // 这是一条注释 来添加注释。计算机会忽略该行 // 之后的所有内容。

Always consider the user experience: write clear prompts before an INPUT statement, and format output so it is easy to read.

始终要考虑用户体验:在 INPUT 语句前写出清晰的提示,并格式化输出使内容易于阅读。


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