📚 Operators and Expressions in Edexcel A-Level Programming | Edexcel A-Level 编程中的运算符与表达式
In Edexcel A-Level Computer Science, programming questions often test your ability to build and evaluate expressions correctly. Operators are the building blocks that combine values, variables, and function calls into meaningful computations. This revision guide covers arithmetic, relational, Boolean, bitwise, and assignment operators, as well as precedence, type conversion, and common exam traps.
在 Edexcel A-Level 计算机科学中,编程题经常考查你正确构建和求值表达式的能力。运算符是将值、变量和函数调用组合成有意义计算的基石。本复习指南涵盖算术、关系、布尔、位运算和赋值运算符,以及优先级、类型转换和常见考试陷阱。
1. Operators and Operands Overview | 运算符与操作数概览
ue or variable on which the operator acts. For example, in 7 + 2, + is the operator, and 7 and 2 are operands.
表达式由运算符和操作数组成。运算符是告诉程序执行特定操作的符号,例如 + 表示加法,== 表示相等。操作数是运算符作用的值或变量。例如,在 7 + 2 中,+ 是运算符,7 和 2 是操作数。
Operators can be classified by the number of operands they require. Unary operators act on one operand, such as the logical NOT operator or unary minus. Binary operators act on two operands, such as a + b. Most languages used in A-Level also have a ternary conditional operator, but Edexcel pseudocode tends to focus on unary and binary operators.
运算符可按所需操作数的数量分类。一元运算符作用于一个操作数,如逻辑非运算或一元负号。二元运算符作用于两个操作数,如 a + b。A-Level 中使用的大多数语言也有三元条件运算符,但 Edexcel 伪代码通常侧重一元和二元运算符。
2. Arithmetic Operators | 算术运算符
Arithmetic operators perform mathematical calculations. The core set includes + (addition), - (subtraction), * (multiplication), / (division), MOD or % (remainder), and DIV or // (integer division). In Edexcel pseudocode, MOD gives the remainder and DIV gives the quotient after integer division.
算术运算符执行数学计算。核心集合包括 +(加)、-(减)、*(乘)、/(除)、MOD 或 %(取余)以及 DIV 或 //(整除)。在 Edexcel 伪代码中,MOD 给出余数,DIV 给出整数除法后的商。
. Similarly, 17 DIV 5 evaluates to 3. The exponentiation operator is often written as ^ or . In Python, 2 3 gives 8, while in pseudocode you may see 2 ^ 3.
例如,17 MOD 5 求值为 2,因为 17 ÷ 5 = 3 余 2。类似地,17 DIV 5 求值为 3。乘方运算符通常写作 ^ 或 。在 Python 中,2 3 得到 8,而在伪代码中你可能会看到 2 ^ 3。
17 MOD 5 = 2 and 17 DIV 5 = 3
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 7 + 2 = 9 |
| - | Subtraction | 10 - 4 = 6 |
| * | Multiplication | 3 * 4 = 12 |
| / | Division | 7 / 2 = 3.5 |
| DIV or // | Integer division | 7 DIV 2 = 3 |
| MOD or % | Remainder | 7 MOD 2 = 1 |
| ^ or ** | Exponentiation | 2 ^ 3 = 8 |
3. Relational / Comparison Operators | 关系/比较运算符
ues and return a Boolean result: TRUE or FALSE. The main operators are = (equal to), <> or ! > (greater than), <= (less than or equal to), and >= (greater than or equal to).
关系运算符比较两个值并返回布尔结果:TRUE 或 FALSE。主要运算符有 =(等于)、<> 或 !=(不等于)、<(小于)、>(大于)、<=(小于等于)和 >=(大于等于)。
ion is to compare x with 5; in many languages this assigns the value instead of testing it.
在 Edexcel 伪代码中,相等通常写作 =,而在 Python 中写作 ==。不要混淆 =(赋值)和 ==(比较)。一个常见的考试错误是当想要将 x 与 5 比较时写成 IF x = 5;在许多语言中这会赋值而不是测试。
| Operator | Meaning | Example |
|---|---|---|
| = or == | Equal to | 5 = 5 → TRUE |
| <> or != | Not equal to | 5 <> 7 → TRUE |
| < | Less than | 3 < 4 → TRUE |
广告 / Sponsored 正版】中公备考2026下年中学初高中中职实习心理教师资格证考试教材中学幼师综合素质教育教学知识与能力历年真题试卷题库复… 心理 备考教辅 · 正版现货 · 学习备考通用 查看详情 / View on Taobao广告 / Sponsored 英国CGP教材 Complete Revision and Exam Practice A-Level Biology… 生物 备考教辅 · 正版现货 · 学习备考通用 查看详情 / View on Taobao更多咨询请联系16621398022(同微信) 备考资讯每日更新,关注不错过 考纲变化 · 科目分析 · 学习方法 ![]() 在微信里长按二维码识别关注 或截图后用「扫一扫 → 相册」选择本图 公众号:tutorhao |
