📚 Operators, Expressions and Control Structures in A-Level Edexcel Programming | A-Level Edexcel 编程中的运算符、表达式与控制结构
In the Edexcel A-Level Programming unit, candidates must be able to read, write and trace code that uses operators, expressions and control structures. These building blocks determine how values are calculated, compared and used to decide the flow of a program. This article explains arithmetic, relational and logical operators, expression evaluation, selection, iteration, and related exam skills.
在 Edexcel A-Level 编程单元中,考生必须能够阅读、编写和跟踪使用运算符、表达式和控制结构的代码。这些基本构件决定了如何计算、比较数值,以及如何决定程序的执行流程。本文解释算术、关系和逻辑运算符、表达式求值、选择结构、迭代结构以及相关考试技巧。
1. Programming Basics and Language Classification | 编程基础与语言分类
Edexcel programming questions are often written in a pseudocode style that resembles a high-level imperative language. You need to recognise assignment, arithmetic, input/output and control constructs without being tied to one specific syntax.
Edexcel 编程题通常使用类似高级命令式语言的伪代码风格。你需要识别赋值、算术运算、输入输出和控制结构,而不必局限于某一种特定语法。
- Assignment uses the ← symbol, for example x ← 5. | 赋值使用 ← 符号,例如 x ← 5。
- Input and output may be shown as INPUT x and OUTPUT x. | 输入和输出可以表示为 INPUT x 和 OUTPUT x。
- Sequences of statements run from top to bottom unless a control structure changes the flow. | 语句按从上到下的顺序执行,除非控制结构改变流程。
2. Arithmetic Operators and Precedence | 算术运算符与优先级
Arithmetic operators include addition (+), subtraction (−), multiplication (×), division (/ or ÷), integer division (DIV) and modulus (MOD). Edexcel pseudocode also uses exponentiation (^) in some questions, so you must follow the given key.
算术运算符包括加法(+)、减法(−)、乘法(×)、除法(/ 或 ÷)、整除(DIV)和取模(MOD)。Edexcel 伪代码在某些题目中也使用指数运算(^),因此你必须遵循题目给出的符号说明。
| Priority | 优先级 | Operator | 运算符 | Meaning | 含义 |
|---|---|---|
| Highest | 最高 | ( ) | Brackets | 括号 |
| ^ | Exponent | 指数 | |
| × / DIV MOD | Multiplicative | 乘除运算 | |
| Lowest | 最低 | + − | Additive | 加减运算 |
Always evaluate brackets first, then powers, then multiplication/division/modulus, and finally addition/subtraction. For example, 3 + 4 × 2 = 11, not 14.
始终先计算括号,然后是指数,再是乘法、除法、整除和取模,最后是加法和减法。例如,3 + 4 × 2 = 11,而不是 14。
3 + 4 × 2 = 3 + 8 = 11
3. Relational and Logical Operators | 关系运算符与逻辑运算符
Relational operators compare two values and return a Boolean result (TRUE or FALSE). Common symbols are =, ≠, , ≤ and ≥. Logical operators combine Boolean values: AND, OR and NOT are the standard set used in Edexcel pseudocode.
关系运算符比较两个值并返回布尔结果(TRUE 或 FALSE)。常见符号有 =、≠、、≤ 和 ≥。逻辑运算符用于组合布尔值:Edexcel 伪代码中常用的标准集合是 AND、OR 和 NOT。
- Relational: = ≠ < > ≤ ≥ | 关系运算符:= ≠ < > ≤ ≥
- Logical: AND OR NOT | 逻辑运算符:AND OR NOT
- AND is TRUE only when both operands are TRUE. | 当两个操作数都为 TRUE 时,AND 结果才为 TRUE。
- OR is FALSE only when both operands are FALSE. | 当两个操作数都为 FALSE 时,OR 结果才为 FALSE。
- NOT reverses the truth value. | NOT 反转真值。
4. Boolean Expressions and Truth Tables | 布尔表达式与真值表
Boolean expressions appear in IF conditions and WHILE loops. You may be asked to complete a truth table or to simplify an expression using De Morgan’s laws. In Edexcel exams, truth tables usually show all combinations of two or three inputs.
布尔表达式出现在 IF 条件和 WHILE 循环中。你可能需要填写真值表,或使用德摩根定律简化表达式。在 Edexcel 考试中,真值表通常显示两个或三个输入的所有组合。
Example expression: A AND (B OR NOT C) | 示例表达式:A AND (B OR NOT C)
| A | B | C | NOT C | B OR NOT C | A AND (B OR NOT C) |
|---|---|---|---|---|---|
| TRUE | TRUE | TRUE | FALSE | TRUE | TRUE |
| TRUE | TRUE | FALSE | TRUE | TRUE | TRUE |
| TRUE | FALSE | TRUE | FALSE | FALSE | FALSE |
| FALSE | TRUE | TRUE | FALSE | TRUE | FALSE |
Complete the remaining rows carefully. In exam answers, use consistent TRUE/FALSE or 1/0 notation as stated in the question.
请仔细填写其余各行。在答题时,请按照题目要求一致地使用 TRUE/FALSE 或 1/
Published by TutorHao | A-Level 编程 Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply