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

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

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

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

Operators are the symbols that tell a computer to perform specific mathematical, relational or logical operations. In Edexcel A-Level Computer Science, you must be able to read, write and trace expressions that combine operators and operands.

运算符是告诉计算机执行特定数学、关系或逻辑操作的符号。在 Edexcel A-Level 计算机科学中,你必须能够阅读、编写并追踪结合了运算符和操作数的表达式。

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

Operators form the core of every executable instruction. Without them, a program could store data but never calculate, compare or decide.

运算符构成了每条可执行指令的核心。没有它们,程序只能存储数据,却无法计算、比较或做出决策。


2. Arithmetic Operators | 算术运算符

The usual arithmetic operators are addition, subtraction, multiplication, division, modulus, integer division and exponentiation. In Python they are written +, -, *, /, %, //, **.

常见的算术运算符包括加、减、乘、除、取模、整除和乘方。在 Python 中它们分别写作 +、-、*、/、%、//、**。

17 % 5 = 2    and    17 // 5 = 3    and    2 ** 3 = 8

Remember that % gives the remainder after division, while // discards the fractional part and returns an integer in Python.

请记住,% 给出除法后的余数,而 // 在 Python 中丢弃小数部分并返回整数。


3. Comparison / Relational Operators | 比较(关系)运算符

Comparison operators compare two values and return a Boolean result: True or False. They are essential in selection and iteration.

比较运算符比较两个值并返回布尔结果:True 或 False。它们在选择和迭代中是必不可少的。

may be written as = or == depending on the context, so always check the question wording.

在 Edexcel 伪代码中,符号可能根据上下文写作 = 或 ==,因此务必核对题目措辞。


4. Logical Operators | 逻辑运算符

Logical operators act on Boolean values. Python uses and, or and not. Many pseudocode specifications show AND, OR, NOT.

逻辑运算符作用于布尔值。Python 使用 and、or 和 not。许多伪代码规范显示 AND、OR、NOT。

(age >= 18) and (country == 'UK')

The expression above is True only when both the age condition and the country condition are True.

上面的表达式仅当年龄条件和国家条件都为 True 时才为 True。


5. Bitwise Operators | 位运算符

Bitwise operators work on binary representations of integers. They are less common in A-Level exams, but you may need to trace bit-level operations such as AND, OR, XOR, NOT, left shift and right shift.

位运算符对整数的二进制表示进行操作。它们在 A-Level 考试中较少出现,但你可能需要追踪位级运算,例如 AND、OR、XOR、NOT、左移和右移。

Example: 5 & 3 = 1 because 0101 and 0011 produce 0001.

示例:5 & 3 = 1,因为 0101 与 0011 得到 0001。


6. Assignment Operators | 赋值运算符

=. Compound assignment operators combine arithmetic with assignment, which shortens code.

基本赋值运算符是 =。复合赋值运算符将算术与赋值结合起来,可以缩短代码。


7. Membership and Identity Operators | 成员与身份运算符

Membership operators test whether a value exists in a sequence. Identity operators test whether two references point to the same object in memory.

成员运算符测试一个值是否存在于序列中。身份运算符测试两个引用是否指向内存中的同一个对象。


广告 / Sponsored

8. Precedence and Associativity | 优先级与结合性

Operator precedence decides the order in which operations are evaluated. In most languages, brackets have the highest priority, then exponent, then multiplication/division, then addition/subtraction, then comparisons, then logical operators.

运算符优先级决定了运算的求值顺序。在大多数语言中,括号优先级最高,然后是乘方、乘除、加减,再然后是比较运算,最后是逻辑运算。

Example: 3 + 4 * 2 equals 11, not 14.

示例:3 + 4 * 2 等于 11,而不是 14。


9. Common Pitfalls in A-Level Exam | A-Level 考试常见易错点

nd ==, misuse integer division, or ignore short-circuit evaluation in logical expressions.

学生经常混淆 = 和 ==,误用整除,或忽略逻辑表达式中的短路求值。


10. Quick Revision Table | 快速复习表

OperatorMeaning 含义Example 示例
+Addition 加3 + 2 = 5
%Modulus 取模7 % 4 = 3
//Integer division 整除7 // 4 = 1
==Equal to 等于5 == 5 → True
andLogical AND 逻辑与True and False → False
inMembership 成员'a' in 'cat' → True

Use this table as a quick check before the exam, but always practise tracing full expressions with mixed operators.

在考试前可以用此表快速自查,但务必练习追踪包含混合运算符的完整表达式。


Published by TutorHao | Programming Revision Series | aleveler.com

广告 / Sponsored
正版长笛考级教材1-10级 中国音乐学院社会艺术水平考级书全国通用教材 附DVD 中国青年 第二套长笛考级基础练习曲教…
艺术设计、音乐 备考教辅 · 正版现货 · 学习备考通用
查看详情 / View on Taobao参考价 ¥117.5
广告 / Sponsored
官方现货 正保会计网校中级会计2026年官方教材中级会计实务财务管理经济法官方教材正版辅导图书可搭应试指南必刷550题…
经济、会计 备考教辅 · 正版现货 · 学习备考通用
查看详情 / View on Taobao参考价 ¥42.05

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

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