OUTPUT and sequence
Cambridge Pseudocode Lesson 1 1:59 English narration · English + 中文 subtitles burned in
Chapters
Transcript
Cambridge exams write algorithms in pseudocode — not Python, not Java.
剑桥考试用伪代码来写算法——不是 Python,也不是 Java。
It is a real notation with real keywords, and the paper expects those exact words.
它是一套真正的写法,有真正的关键字,而考卷要求的就是那些确切的词。
Here are the same three steps in both, and they look almost identical, which is exactly the danger: only the left one earns marks.
这里是同样的三个步骤的两种写法,它们看起来几乎一样, 而这恰恰就是危险所在:只有左边那个能拿分。
The good news is that on this page you can run the pseudocode, so you find out immediately.
好消息是在这个页面上你可以运行伪代码,所以你会立刻知道结果。
The first idea has a name you will be asked for.
第一个概念有一个你会被问到的名字。
The computer runs the first line, then the second, then the third, in the order you wrote them.
计算机先运行第一行,然后第二行,然后第三行, 按你写下的顺序执行。
That order is called sequence, and it is one of the three control structures on the syllabus — selection and iteration are the other two, and they arrive in lessons five and seven.
那个顺序叫做"顺序结构", 它是考纲上三种控制结构之一—— 另外两种是选择和循环,它们会在第 5 课和第 7 课出现。
OUTPUT displays a value on the screen.
OUTPUT 把一个值显示在屏幕上。
Three rules cover almost every mark here.
三条规则几乎覆盖了这里的所有分数。
A piece of text goes inside double quotes.
一段文字要放在双引号里面。
A number is written bare, with no quotes at all.
一个数字光着写,完全不加引号。
And each OUTPUT starts a new line, which is how the output on the right lines up with the statements on the left.
而每一个 OUTPUT 都会另起一行, 这就是右边的输出和左边的语句能一一对上的原因。
You can list several items after one OUTPUT, separated by commas, and they print side by side with no gap at all — which is why the space you want is written inside the quotes.
你可以在一个 OUTPUT 后面列出好几项,用逗号分开, 它们会并排打印出来,中间完全没有空隙—— 这就是为什么你想要的那个空格要写在引号里面。
Compare that with writing two OUTPUTs: those give two separate lines.
再和写两个 OUTPUT 比一比:那会得到两行独立的输出。
The comma is a join; a new OUTPUT is a line break.
逗号是连接;一个新的 OUTPUT 是换行。
Four things to take with you.
带走四点。
One: pseudocode is the notation the exam marks.
第一:伪代码就是考卷所批改的那套写法。
Two: statements run top to bottom, and that is sequence.
第二:语句从上往下运行,这就是顺序结构。
Three: text needs double quotes and numbers do not.
第三:文字要双引号,数字不要。
Four: a comma joins items on one line.
第四:逗号把几项连在同一行上。
Now write the three tasks and press Run.
现在把那三道题写出来,然后按 Run。