📚 A-Level Edexcel Programming: Operators, Expressions and Control Flow | A-Level Edexcel 编程:运算符、表达式与控制流
In Edexcel A-Level Computer Science, programming questions test your ability to trace, write and correct pseudocode. Operators, expressions and control flow form the foundation of nearly every algorithm you will encounter on Paper 1 and in the practical programming project.
在 Edexcel A-Level 计算机科学考试中,编程题考查跟踪、编写和纠正伪代码的能力。运算符、表达式和控制流是你在 Paper 1 和编程项目中几乎所有算法的基础。
1. Data Types and Variables | 数据类型与变量
Before using any operator, you must know the data type of each operand. Edexcel pseudocode uses five core types: integer, real, Boolean, character and string.
在使用任何运算符之前,你必须知道每个操作数的数据类型。Edexcel 伪代码使用五种核心类型:整数、实数、布尔、字符和字符串。
Variables must be declared with a clear data type. A common exam mistake is mixing types, such as trying to add an integer to a string without converting first.
变量必须声明清楚的数据类型。常见考试错误是混合类型,例如未先转换就将整数与字符串相加。
- INTEGER: whole numbers, e.g. -3, 0, 42
整数:如 -3、0、42 - REAL: numbers with a fractional part, e.g. 3.14
实数:带小数部分的数字,如 3.14 - BOOLEAN: TRUE or FALSE
布尔:TRUE 或 FALSE - CHAR: a single character, e.g. ‘A’
字符:单个字符,如 ‘A’ - STRING: a sequence of characters, e.g. “hello”
字符串:字符序列,如 “hello”
2. Arithmetic Operators | 算术运算符
Arithmetic operators allow you to perform calculations on numeric data. Edexcel includes the standard operators plus integer division and modulo.
算术运算符允许你对数值数据执行计算。Edexcel 包括标准运算符以及整数除法和取模运算。
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 5 + 3 = 8 |
| – | Subtraction | 5 – 3 = 2 |
| * | Multiplication | 5 * 3 = 15 |
| / | Division (real result) | 5 / 2 = 2.5 |
| DIV | Integer division | 5 DIV 2 = 2 |
| MOD | Remainder after division | 5 MOD 2 = 1 |
Be careful with DIV and MOD when negative numbers are involved. In Edexcel pseudocode, DIV truncates towards zero, and MOD gives the remainder with the sign of the dividend.
当涉及负数时,使用 DIV 和 MOD 要小心。在 Edexcel 伪代码中,DIV 向零截断,MOD 给出带被除数符号的余数。
3. Relational and Comparison Operators | 关系与比较运算符
Comparison operators return a Boolean result and are essential for building conditions in selection and iteration.
比较运算符返回布尔结果,并且在选择和迭代中构建条件时必不可少。
- = equal to
等于 - ≠ or != not equal to
不等于 - < less than
小于 - > greater than
大于 - <= less than or equal to
小于或等于 - >= greater than or equal to
大于或等于
When comparing strings, the comparison is typically based on lexicographic order using the character set’s collating sequence. For example, “apple” < “banana” because ‘a’ comes before ‘b’.
比较字符串时,通常根据字符集的排序序列按字典顺序比较。例如,”apple” < “banana”,因为 ‘a’ 在 ‘b’ 之前。
4. Boolean Operators: AND, OR, NOT | 布尔运算符:AND、OR、NOT
Boolean operators combine or invert logical values. You must know their truth tables and how short-circuit evaluation works in pseudocode.
布尔运算符组合或反转逻辑值。你必须了解它们的真值表以及伪代码中短路求值的工作原理。
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| TRUE | TRUE | TRUE | TRUE | FALSE |
| TRUE | FALSE | FALSE | TRUE | FALSE |
| FALSE | TRUE | 更多咨询请联系16621398022(同微信)
CommentsMore posts |
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导