Operators, Expressions and Precedence in Edexcel A-Level Programming | Edexcel A-Level编程运算符、表达式与优先级

📚 Operators, Expressions and Precedence in Edexcel A-Level Programming | Edexcel A-Level编程运算符、表达式与优先级

In Edexcel A-Level Computer Science, programming questions reward precise use of operators, expressions and precedence. Whether you trace pseudocode or write Python, a single wrong operator can change the entire logic of an algorithm. This revision guide covers the operators and expression rules you need for the qualification.

在Edexcel A-Level计算机科学中,编程题目会考查你对运算符、表达式和优先级的精确使用。无论你是在追踪伪代码还是编写Python,一个错误的运算符都可能改变整个算法的逻辑。本复习指南涵盖本资格认证所需的运算符和表达式规则。


1. Why Operators Matter | 为什么运算符重要

Operators are symbols that tell the computer to perform a specific operation on one or more operands. An expression is a combination of values, variables, operators and function calls that can be evaluated to produce a single result. Edexcel exams test both your ability to read expressions in pseudocode and your ability to write correct expressions in a high-level language such as Python.

运算符是告诉计算机对一个或多个操作数执行特定操作的符号。表达式是由值、变量、运算符和函数调用组成的组合,可以被求值得到单一结果。Edexcel考试既考查你阅读伪代码中表达式的能力,也考查你使用Python等高级语言编写正确表达式的能力。


2. Arithmetic Operators | 算术运算符

The core arithmetic operators in Edexcel pseudocode are +, -, *, /, DIV, MOD and ^. You must recognise each one and know how it behaves with integer and real operands.

Edexcel伪代码中的核心算术运算符是+、-、*、/、DIV、MOD和^。你必须认识每一个运算符,并知道它们在整数和实数操作数上的行为。

Operator Meaning Pseudocode example Python equivalent
+ Addition | 加 3 + 2 = 5 3 + 2 = 5
Subtraction | 减 7 – 4 = 3 7 – 4 = 3
* Multiplication | 乘 6 * 4 = 24 6 * 4 = 24
/ Real division | 实数除法 7 / 2 = 3.5 7 / 2 = 3.5
DIV Integer division | 整除 17 DIV 5 = 3 17 // 5 = 3
MOD Remainder | 取余 17 MOD 5 = 2 17 % 5 = 2
^ Exponent | 幂 2^3 = 8 2 ** 3 = 8

Notice that Edexcel pseudocode uses ^ for powers, while Python uses **. In both contexts, multiplication and division are evaluated before addition and subtraction unless parentheses change the order.

请注意,Edexcel伪代码使用^表示幂,而Python使用**。在两种环境中,乘法和除法都先于加法和减法求值,除非括号改变顺序。


3. DIV and MOD | 整除与取余

DIV gives the whole-number quotient when one integer is divided by another, and MOD gives the remainder. These operations are extremely common in algorithm questions involving digits, cycles, calendars and validation rules.

DIV给出一个整数除以另一个整数时的整数商,MOD给出余数。这些运算在涉及数字、周期、日历和验证规则的算法题中非常常见。

17 DIV 5 = 3    17 MOD 5 = 2

In Python the same results are produced by // and %: 17 // 5 gives 3 and 17 % 5 gives 2. For positive integers this is straightforward, and most exam examples use positive values.

在Python中,同样的结果由//和%产生:17 // 5得到3,17 % 5得到2。对于正整数,这很简单,大多数考试示例都使用正值。


4. Relational and Comparison Operators | 关系与比较运算符

Relational operators compare two values and return a Boolean result: TRUE or FALSE. They are used in IF statements, WHILE loops and validation checks.

关系运算符比较两个值并返回布尔结果:TRUE或FALSE。它们用于IF语句、WHILE循环和验证检查中。

Operator Meaning Example
== Equal to | 等于 5 == 5 evaluates to TRUE
!= Not equal to | 不等于 5 != 4 evaluates to TRUE
< Less than | 小于 3 < 8 evaluates to TRUE
> Greater than | 大于 10 > 4 evaluates to TRUE
<= Less than or equal to | 小于等于 6 <= 6 evaluates to TRUE
>= Greater than or equal to | 大于等于 9 >= 8 evaluates to TRUE

A key exam hazard is confusing = with ==. In Edexcel pseudocode and Python, a single = is assignment, while == is the comparison for equality. Using = where == is required will usually cause an error or unexpected behaviour.

一个关键的考试易错点是将=和==混淆。在Edexcel伪代码和Python中,单个=用于赋值,而==用于比较相等。在需要==的地方使用=通常会导致错误或意外行为。


5. Boolean and Logical Operators | 布尔与逻辑运算符

Boolean operators AND, OR and NOT combine or invert Boolean conditions. They are essential for constructing compound conditions in IF, WHILE and REPEAT structures.

布尔运算符AND、OR和NOT用于组合或反转布尔条件。它们在构建IF、WHILE和REPEAT结构中的复合条件时必不可少。

A B A AND B A OR B NOT A
TRUE TRUE TRUE TRUE FALSE
TRUE FALSE FALSE TRUE FALSE
FALSE TRUE FALSE TRUE TRUE

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