Programming Fundamentals and Computational Thinking | 编程基础与计算思维

📚 Programming Fundamentals and Computational Thinking | 编程基础与计算思维

This revision guide covers the core programming and computational thinking skills required for Edexcel A-Level Computer Science. It is designed to help you understand how programs are designed, written, tested and evaluated, and to prepare for both Paper 1 and Paper 2 programming questions.

本复习指南涵盖 Edexcel A-Level 计算机科学所需的核心编程与计算思维技能。它旨在帮助你理解程序如何被设计、编写、测试和评估,并为 Paper 1 和 Paper 2 的编程题做好准备。


1. Computational Thinking | 计算思维

Computational thinking involves breaking down complex problems into smaller, more manageable parts. The three key techniques are decomposition, pattern recognition and abstraction. Decomposition means splitting a problem into sub-problems. Pattern recognition identifies similarities with previously solved problems. Abstraction focuses on relevant information while ignoring unnecessary detail.

计算思维涉及将复杂问题分解为更小、更易于处理的部分。三种关键技术是分解、模式识别和抽象。分解意味着把一个问题拆分成若干子问题。模式识别识别与已解决问题之间的相似性。抽象则聚焦于相关信息,忽略不必要的细节。

Algorithmic thinking is the process of defining a clear, step-by-step solution to a problem. A good algorithm is precise, finite and unambiguous. These skills are explicitly assessed in Edexcel programming questions, where you must design a solution before writing code.

算法思维是定义一个清晰、逐步解决问题的过程。好的算法是精确、有限且无歧义的。这些技能在 Edexcel 编程题中会被直接考查,你必须在编写代码之前先设计解决方案。

  • Decomposition – breaking a problem into smaller parts (分解 – 将问题拆分为更小的部分)
  • Pattern recognition – spotting similarities with known problems (模式识别 – 发现与已知问题的相似性)
  • Abstraction – ignoring unnecessary detail to focus on key features (抽象 – 忽略不必要细节,聚焦关键特征)

2. Programming Paradigms | 编程范式

Edexcel expects awareness of different programming paradigms, mainly procedural, object-oriented and event-driven. Procedural programming uses step-by-step instructions and functions to manipulate data. Object-oriented programming organises code into classes and objects with attributes and methods. Event-driven programming responds to user actions such as button clicks.

Edexcel 要求了解不同的编程范式,主要是过程式、面向对象和事件驱动。过程式编程使用逐步指令和函数来操作数据。面向对象编程将代码组织成具有属性和方法的类和对象。事件驱动编程则响应用户操作,例如按钮点击。

Paradigm Key Idea Typical Use
Procedural Series of instructions; functions/procedures Scientific calculations, simple utilities
Object-oriented Classes, objects, encapsulation, inheritance Large applications, GUI systems
Event-driven Code executes in response to events Interactive interfaces, mobile apps

You should be able to compare these paradigms and justify why one may be more suitable for a given problem. For example, an object-oriented approach is often chosen when the system models real-world entities with shared behaviour.

你应该能够比较这些范式,并说明为什么某个范式更适合给定的问题。例如,当系统对具有共同行为的现实世界实体进行建模时,通常会选择面向对象方法。


3. Variables, Constants and Data Types | 变量、常量与数据类型

Programs store data in named memory locations called variables. A constant is a value that cannot be changed during execution. Common data types include integer, real (float), Boolean, character, string and date/time. Choosing the correct data type is important for memory efficiency and for validation.

程序在称为变量的命名内存位置中存储数据。常量是在执行期间不能更改的值。常见的数据类型包括整数、实数(浮点)、布尔、字符、字符串和日期/时间。选择正确的数据类型对于内存效率和验证非常重要。

Data Type Description Example
Integer Whole number 42
Real / Float Decimal number 3.14
Boolean True or False only True
Character Single symbol ‘A’
String Sequence of characters “Hello”

Implicit and explicit type conversion can cause errors if not handled carefully. In many languages, adding an integer to a floating-point number promotes the integer to a float automatically, but converting a string to an integer requires explicit casting or parsing.

隐式和显式类型转换如果不小心处理可能会导致错误。在许多语言中,整数与浮点数相加会自动将整数提升为浮点数,但将字符串转换为整数则需要显式转换或解析。


4. Control Structures: Sequence, Selection, Iteration | 控制结构:顺序、选择、迭代

All programs are built from three control structures: sequence, selection and iteration. Selection uses IF, ELSE IF and ELSE statements to make decisions. Iteration repeats code using FOR, WHILE or REPEAT UNTIL loops. Sequence is the default order of execution.

所有程序都由三种控制结构构建:顺序、选择和迭代。选择使用 IF、ELSE IF 和 ELSE 语句来做出决策。迭代使用 FOR、WHILE 或 REPEAT UNTIL 循环来重复代码。顺序是默认的执行顺序。

Below is a typical selection statement written in pseudocode. It assigns a grade based on a numeric score. Note the use of ≥ for ‘greater than or equal to’.

下面是一个用伪代码编写的典型选择语句。它根据数值分数分配等级。注意使用 ≥ 表示“大于或等于”。

IF score ≥ 75 THEN
  grade = ‘A’
ELSE IF score ≥ 60 THEN
  grade = ‘B’
ELSE
  grade = ‘C’
END IF

Iteration can be count-controlled or condition-controlled. A FOR loop executes a fixed number of times, while a WHILE loop continues as long as a condition is true. A REPEAT UNTIL loop always executes at least once before checking the condition.

迭代可以是计数控制或条件控制。FOR 循环执行固定次数,而 WHILE 循环在条件为真时继续执行。REPEAT UNTIL 循环在检查条件之前至少执行一次。


5. Functions and Procedures | 函数与过程

A function is a named block of code that returns a value, while a procedure performs a task but returns no value. Parameters allow data to be passed into functions and procedures. Using functions improves modularity, reusability and readability of code.

函数是一个返回值的命名代码块,而过程执行任务但不返回值。参数允许将数据传递给函数和过程。使用函数可以提高代码的模块化、可重用性和可读性。

Parameters can be passed by value or by reference. In pass by value, a copy of the argument is made, so the original variable is not changed. In pass by reference, the function can modify the original variable’s value. Edexcel questions often ask you to trace the effect of parameter passing.

参数可以按值或按引用传递。在按值传递中,会创建实参的副本,因此原始变量不会被改变。在按引用传递中,函数可以修改原始变量的值。Edexcel 题目常要求你跟踪参数传递的效果。

  • Functions return a value; procedures do not (函数返回值;过程不返回值)
  • Parameters improve code reuse (参数提高代码重用性)
  • Modular code is easier to test and debug (模块化代码更易于测试和调试)

6. Data Structures: Arrays, Lists, Records | 数据结构:数组、列表、记录

Arrays store multiple elements of the same data type in contiguous memory locations. A 1D array is like a list, while a 2D array represents a table or matrix. Indexing usually starts at 0, so the first element is array[0].

数组在连续的内存位置中存储多个相同数据类型的元素。一维数组类似列表,而二维数组代表表格或矩阵。索引通常从 0 开始,因此第一个元素是 array[0]。

Records group related fields of different data types into one structure. For example, a student record might contain a string name, an integer age and a real average mark. Lists in languages like Python are dynamic and can hold mixed types, but this flexibility comes with memory overhead.

记录将不同数据类型的相关字段组合成一个结构。例如,学生记录可能包含字符串姓名、整数年龄和实数平均分。像 Python 这样的语言中的列表是动态的,可以容纳混合类型,但这种灵活性会带来内存开销。

Understanding the distinction between a static array, which has a fixed size, and a dynamic list, which can grow or shrink, is essential for answering Edexcel data structure questions.

理解静态数组(大小固定)与动态列表(可以扩展或收缩)之间的区别,对于回答 Edexcel 数据结构问题至关重要。


7. File Handling and Exceptions | 文件处理与异常

File handling allows programs to read from and write to external files such as text or CSV files. Common operations include open, read, write, append and close. Opening a file usually requires specifying a mode: read (‘r’), write (‘w’), append (‘a’) or read/write (‘r+’).

文件处理允许程序读取和写入外部文件,例如文本文件或 CSV 文件。常见操作包括打开、读取、写入、追加和关闭。打开文件通常需要指定模式:读取 (‘r’)、写入 (‘w’)、追加 (‘a’) 或读写 (‘r+’)。

Exception handling uses TRY-EXCEPT blocks to manage runtime errors like missing files or invalid input without crashing the program. When an error occurs inside the TRY block, control jumps to the EXCEPT block where a recovery action can be taken. This improves robustness.

异常处理使用 TRY-EXCEPT 块来管理运行时错误,例如文件缺失或输入无效,而不会使程序崩溃。当 TRY 块内发生错误时,控制权会跳转到 EXCEPT 块,在那里可以采取恢复措施。这提高了程序的健壮性。

  • Open a file before reading or writing (在读写之前打开文件)
  • Close files after use to free resources (使用后关闭文件以释放资源)
  • Use TRY-EXCEPT to handle file not found errors (使用 TRY-EXCEPT 处理文件未找到错误)

8. Algorithms: Searching and Sorting | 算法:搜索与排序

Searching algorithms include linear search and binary search. Linear search checks every element sequentially with average time complexity O(n). Binary search requires a sorted list and halves the search space each time, giving O(log n).

搜索算法包括线性搜索和二分搜索。线性搜索顺序检查每个元素,平均时间复杂度为 O(n)。二分搜索要求列表有序,每次将搜索空间减半,时间复杂度为 O(log n)。

Linear search: O(n)   |   Binary search: O(log n)

Sorting algorithms include bubble sort, insertion sort and merge sort. Bubble sort repeatedly compares adjacent elements and swaps them if they are out of order. Insertion sort builds the sorted list one element at a time. Merge sort divides the list into halves, sorts each half recursively, then merges them.

排序算法包括冒泡排序、插入

Published by TutorHao | A-Level 编程 Revision Series | aleveler.com

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

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version