← 返回资讯屏轩教育 · 行业资讯

Operators and Expressions in Programming | 编程中的运算符与表达式

2026-08-29 15:34 · 本文部分内容由AI辅助创作

📚 Operators and Expressions in Programming | 编程中的运算符与表达式

In A-Level programming, a large part of your success depends on how precisely you can write and evaluate expressions. Operators are the symbols that tell the computer what action to perform on one or more operands, while expressions combine operators, operands, and function calls into values.

在 A-Level 编程中,能否准确书写和求值表达式在很大程度上决定了你的成绩。运算符是告诉计算机对一个或多个操作数执行什么操作的符号,而表达式将运算符、操作数和函数调用组合成值。


1. Operators as Fundamental Building Blocks | 运算符是基本构建块

In Edexcel A-Level Computer Science, a program is built from statements, and most statements contain expressions. An expression is a combination of operators, operands, constants, variables, and function calls that the program evaluates to produce a value. For example, in 'total + 5', 'total' and '5' are operands, '+' is the operator, and the whole line forms an expression. Operators are classified into arithmetic, relational, logical, bitwise, and assignment operators. Understanding these categories is essential because exam questions often ask you to trace code, simplify Boolean expressions, or spot errors in operator use.

在 Edexcel A-Level 计算机科学中,程序由语句组成,而大多数语句都包含表达式。表达式是运算符、操作数、常量、变量和函数调用的组合,程序对它们求值以产生一个值。例如,在 'total + 5' 中,'total' 和 '5' 是操作数,'+' 是运算符,整行构成一个表达式。运算符分为算术、关系、逻辑、位和赋值运算符。理解这些类别非常重要,因为考试题经常要求你跟踪代码、简化布尔表达式或找出运算符使用中的错误。

Arithmetic operators perform calculations, relational operators compare values, logical operators combine Boolean conditions, and assignment operators store results. Each category has its own syntax rules and expected operand types, so recognising which category a symbol belongs to is the first step in any trace-table or code-correction task.

算术运算符执行计算,关系运算符比较值,逻辑运算符组合布尔条件,赋值运算符存储结果。每一类都有各自的语法规则和预期操作数类型,因此识别符号属于哪一类是所有跟踪表或代码修正任务的第一步。


2. Arithmetic Operators and Integer Division | 算术运算符与整数除法

The core arithmetic operators are addition '+', subtraction '−', multiplication '×', real division '/', integer division 'DIV', and exponentiation '^'. In Edexcel pseudo code, integer division 'DIV' scarding the remainder. For example, 17 DIV 5 gives 3, while 17 / 5 gives 3.4. Python uses '//' for integer division and '/' the same values would be written as 17 // 5 and 17 / 5. Many students lose marks by using '/' uestion requires whole-number division, especially when counting complete groups or pages.

核心算术运算符包括加法 '+'、减法 '−'、乘法 '×'、实数除法 '/'、整数除法 'DIV' 和指数 '^'。在 Edexcel 伪代码中,整数除法 'DIV' 返回商的整数部分并舍弃余数。例如,17 DIV 5 得到 3,而 17 / 5 得到 3.4。Python 使用 '//' 表示整数除法、'/' 表示实数除法,因此同样的值可以写为 17 // 5 和 17 / 5。很多学生在题目要求整数除法时误用了 '/',尤其是在统计完整组数或页数时容易失分。

17 DIV 5 = 3, 17 MOD 5 = 2

Exponentiation is written as '^' in pseudo code, such as 23 = 8, while Python uses '**' estions, integer division is frequently used to split a total into whole parts, for example converting minutes into hours and minutes: 'hours ← totalMinutes DIV 60' and 'remainingMinutes ← totalMinutes MOD 60'.

伪代码中指数写作 '^',例如 23 = 8,而 Python 使用 '**'。注意区分指数与乘法,并在没有括号指示的情况下先于 DIV 或 MOD 计算。在 A-Level 题目中,整数除法经常用于将总数拆分为整份,例如将分钟转换为小时和分钟:'hours ← totalMinutes DIV 60' 以及 'remainingMinutes ← totalMinutes MOD 60'。


广告 / Sponsored

3. Modulus and Its Applications | 取模运算及其应用

The modulus operator 'MOD' . For example, 17 MOD 5 returns 2 because 5 goes into 17 three times with 2 left over. A typical exam question might ask you to write a condition to test whether a number is even: 'IF number MOD 2 = 0 THEN'. Modulus is also widely used to wrap an index around an array: 'index ← (index + 1) MOD length'.

取模运算符 'MOD' 返回整数除法后的余数。它在判断整除性、循环遍历列表和查找规律时非常有用。例如,17 MOD 5 返回 2,因为 5 进入 17 三次后余 2。常见考试题可能要求你写出判断一个数是否为偶数的条件:'IF number MOD 2 = 0 THEN'。取模还广泛用于将数组索引回绕:'index ← (index + 1) MOD length'。

on and modulus, the relationship is: dividend = divisor × quotient + remainder. This means '17 = 5 × 3 + 2' -table tasks, each MOD step should be written out separately to avoid arithmetic mistakes.

在处理整数除法和取模

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

广告 / Sponsored
华硕Pad 12.2英寸平板二合一电脑Type-C扩展坞USB-C分线器雷电4拓展坞转HDMI投屏转换器转接头网口hu…
学习备考用品 · 正版现货 · 学习备考通用
查看详情 / View on Taobao参考价 ¥119.0
广告 / Sponsored
吾空凌云A14E 2026 14英寸电脑支架笔记本散热托支撑架子增高悬空可调节升降铝合金桌面办公配件折叠便携式
学习备考用品 · 正版现货 · 学习备考通用
查看详情 / View on Taobao参考价 ¥56.0

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

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao