Appearance
3.3 Mathematical Expressions 数学表达式
The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.
- 程序中语句的排序和组合方式决定了计算结果。程序结合迭代和选择结构来表示重复并做出决策来处理各种输入值。
核心要点 Core Points
An algorithm is a finite set of instructions that accomplish a specific task.
- 一个算法是完成特定任务的有限指令集。
Algorithms can be expressed in various ways (natural language, diagrams, pseudocode) beyond programming languages.
- 算法可以用各种方式表达(自然语言、图表、伪代码),而不仅仅是编程语言。
Algorithms executed by programs are implemented using programming languages.
- 由程序执行的算法使用编程语言实现。
Every algorithm can be constructed using combinations of sequencing, selection, and iteration.
- 每个算法都可以使用排序、选择和迭代的组合来构建。
Sequencing is the application of each step of an algorithm in the order in which the code statements are given.
- 排序是按代码语句给出的顺序应用算法的每个步骤。
A code statement is a part of program code that expresses an action to be carried out.
- 代码语句是程序代码中表达要执行的动作的部分。
An expression can consist of a value, a variable, an operator, or a procedure call that returns a value.
- 表达式可以由值、变量、运算符或返回值的过程调用组成。
Expressions are evaluated to produce a single value.
- 表达式被计算以产生单个值。
The evaluation of expressions follows a set order of operations defined by the programming language.
- 表达式的计算遵循编程语言定义的一组操作顺序。
Sequential statements execute in the order they appear in the code segment.
- 顺序语句按它们在代码段中出现的顺序执行。
Clarity and readability are important considerations when expressing an algorithm in a programming language.
- 在编程语言中表达算法时,清晰性和可读性是重要的考虑因素。
Arithmetic operators are part of most programming languages and include addition, subtraction, multiplication, division, and modulus operators.
- 算术运算符是大多数编程语言的一部分,包括加法、减法、乘法、除法和模运算符。
The exam reference sheet provides a MOD b, which evaluates to the remainder when a is divided by b. Assume that a is an integer greater than or equal to 0 and b is an integer greater than 0. For example, 17 MOD 5 evaluates to 2.
- 考试参考表提供了a MOD b,当a除以b时计算余数。假设a是大于或等于0的整数,b是大于0的整数。例如,17 MOD 5计算为2。
The exam reference sheet provides the arithmetic operators +, -, *, /, and MOD. Text and Block: a + b, a - b, a * b, a / b, a MOD b. These are used to perform arithmetic on a and b. For example, 17 / 5 evaluates to 3.4.
- 考试参考表提供了算术运算符+、-、*、/和MOD。文本和块:a + b、a - b、a * b、a / b、a MOD b。这些用于对a和b执行算术运算。例如,17 / 5计算为3.4。
The order of operations used in mathematics applies when evaluating expressions. The MOD operator has the same precedence as the * and / operators.
- 在计算表达式时应用数学中使用的运算顺序。MOD运算符与*和/运算符具有相同的优先级。
学生活动 Student Activities
Express an algorithm that uses sequencing without using a programming language.
- 表达一个使用排序而不使用编程语言的算法。
Represent a step-by-step algorithmic process using sequential code statements.
- 使用顺序代码语句表示逐步算法过程。
Evaluate expressions that use arithmetic operators.
- 计算使用算术运算符的表达式。
