📚 Edexcel A-Level Programming Operators: Arithmetic, Comparison, Boolean and Precedence | Edexcel A-Level 编程运算符:算术、比较、布尔与优先级
Operators are the building blocks of any expression in computer science. In the Edexcel A-Level programming units, you are expected to use arithmetic, comparison, Boolean and string operators confidently within pseudocode and trace tables. A solid understanding of operators prevents logic errors and helps you predict the exact output of an algorithm under examination conditions.
运算符是计算机科学中任何表达式的基本构建模块。在 Edexcel A-Level 编程单元中,你需要能够在伪代码和追踪表中熟练使用算术、比较、布尔和字符串运算符。扎实掌握运算符可以防止逻辑错误,并帮助你在考试条件下准确预测算法的输出。
1. What is an operator? | 什么是运算符?
An operator is a symbol or keyword that tells the program to perform a specific operation on one or more values called operands. For example, in 3 + 5 the operator is + and the operands are 3 and 5. Operators are classified by the number of operands: unary operators take one operand, such as NOT or unary minus, while binary operators take two operands, such as +, AND and =.
运算符是告诉程序对一个或多个称为操作数的值执行特定操作的符号或关键字。例如,在 3 + 5 中,运算符是 +,操作数是 3 和 5。运算符按操作数数量分类:一元运算符需要一个操作数,例如 NOT 或一元负号;二元运算符需要两个操作数,例如 +、AND 和 =。
2. Arithmetic operators | 算术运算符
Edexcel pseudocode includes six common arithmetic operators: + for addition, – for subtraction, * for multiplication, / for real division, DIV for integer division, and MOD for the remainder after integer division. The less familiar ones are DIV and MOD because they work only with integers and are frequently tested in trace tables and dry-run questions.
Edexcel 伪代码包含六种常见算术运算符:+ 加法、– 减法、* 乘法、/ 实数除法、DIV 整数除法和 MOD 求余。较不熟悉的是 DIV 和 MOD,因为它们仅适用于整数,并且经常在追踪表与手工运行题中考查。
| Operator | Meaning | Example | Result |
|---|---|---|---|
| + | addition | 7 + 2 | 9 |
| – | subtraction | 9 – 4 | 5 |
| * | multiplication | 6 * 8 | 48 |
| / | real division | 7 / 2 | 3.5 |
| DIV | integer division | 7 DIV 2 | 3 |
| MOD | remainder | 7 MOD 2 | 1 |
3. Integer division and modulus | 整数除法与取模
DIV produces the whole-number quotient after discarding the fractional part. MOD produces the remainder after integer division. For example, 23 DIV 5 = 4 and 23 MOD 5 = 3, because 5 × 4 + 3 = 23. In Edexcel exam questions, the values are usually positive integers, so you do not need to worry about negative-value conventions unless the paper states otherwise.
DIV 产生丢弃小数部分后的整数商。MOD 产生整数除法后的余数。例如,23 DIV 5 = 4 且 23 MOD 5 = 3,因为 5 × 4 + 3 = 23。在 Edexcel 考试中,数值通常为正整数,因此除非试卷另有说明,否则无需担心负值约定。
dividend = divisor × quotient + remainder
4. Comparison operators | 比较运算符
Comparison or relational operators compare two values and return a Boolean result: TRUE or FALSE. Edexcel notation commonly includes =, <>, <, >, <= and >=. Do not confuse = with assignment; in an expression, equality is a question, not a command.
比较或关系运算符比较两个值并返回布尔结果:TRUE 或 FALSE。Edexcel 记号通常包括 =、<>、<、>、<= 和 >=。不要将 = 与赋值混淆;在表达式中,相等是一个问题,而不是一个命令。
| Operator | Meaning | Example | Result |
|---|---|---|---|
| = | equal to | 4 = 4 | TRUE |
| <> | not equal to | 4 <> 5 | TRUE |
| < | less than | 3 < 7 | TRUE |
| > | greater than | 9 > 2 | TRUE |
| <= | less than or equal to |
Published by TutorHao | A-Level 编程 Revision Series | aleveler.com 更多咨询请联系16621398022(同微信) CommentsMore posts |
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply