跳到主要内容
学科

IGCSE 计算机科学

剑桥 IGCSE 计算机科学(0478)包含十个主题,分布在两份试卷中:数据表示、数据传输、硬件、 软件、互联网及其应用、自动化与新兴技术、算法设计与问题求解、编程、数据库、布尔逻辑。

卷一考理论,按精确术语评分——RAM 与 ROM 的区别、编译器与解释器的区别、validation 与 verification 的区别。这些是定义分,用自己的话改述通常拿不到。卷二考问题求解与编程,分数 给的是可行的方法:追踪表、伪代码,以及真正能运行的代码。

进制与二进制运算值得优先掌握——它们既独立成题,又出现在数据传输、逻辑与硬件之中。本站笔记 按考纲主题逐页编写,算法同时给出伪代码与 Python;本站 /code 课程可在浏览器中直接运行, 你可以真正执行一个想法,而不是希望它能跑通。

IGCSE 计算机科学历年真题

训练全部词汇
  • 1

    数据表示

    讲义 词汇表
    1.1

    计算机为何使用二进制

    一台计算机只能用两个状态工作:开和关。你把这些写成 1 和 0。一个只用两个数字(digits)的系统叫二进制(binary,基数 2)。

    一片蓝色的二进制数字,0 和 1
    计算机把所有数据——数字、文本、声音和图像——表示为 0 和 1 的二进制串

    每种数据(data)——数字、文本、声音和图像——在计算机能使用它之前都必须被变成二进制。计算机用逻辑门(logic gates)处理这个二进制,并把它存储在寄存器(registers,处理器(processor)内部的小的、快速的存储)中。

    放大下的一个微处理器的硅晶片
    一个微处理器容纳数百万个微小的晶体管,每个是一个开(1)或关(0)的开关——二进制的物理基础
    词汇表 训练
    英文 中文 拼音
    digit 数字 shù zì
    binary 二进制 èr jìn zhì
    data 数据 shù jù
    logic gate 逻辑门 luó jí mén
    processor 处理器 chǔ lǐ qì
    register 寄存器 jì cún qì
    1.1

    数制

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand how and why computers use binary to represent all forms of data • Any form of data needs to be converted to binary to be processed by a computer • Data is processed using logic gates and stored in registers
    2 (a) Understand the denary, binary and hexadecimal number systems (b) Convert between (i) positive denary and positive binary (ii) positive denary and positive hexadecimal (iii) positive hexadecimal and positive binary • Denary is a base 10 system • Binary is a base 2 system • Hexadecimal is a base 16 system • Values used will be integers only • Conversions in both directions, e.g. denary to binary or binary to denary • Maximum binary number length of 16-bit
    3 Understand how and why hexadecimal is used as a beneficial method of data representation • Areas within computer science that hexadecimal is used should be identified • Hexadecimal is easier for humans to understand than binary, as it is a shorter representation of binary
    4 (a) Add two positive 8-bit binary integers (b) Understand the concept of overflow and why it occurs in binary addition • An overflow error will occur if the value is greater than 255 in an 8-bit register • A computer or a device has a predefined limit that it can represent or store, for example 16-bit • An overflow error occurs when a value outside this limit should be returned
    5 Perform a logical binary shift on a positive 8-bit binary integer and understand the effect this has on the positive binary integer • Perform logical left shifts • Perform logical right shifts • Perform multiple shifts • Bits shifted from the end of the register are lost and zeros are shifted in at the opposite end of the register • The positive binary integer is multiplied or divided according to the shift performed • The most significant bit(s) or least significant bit(s) are lost
    6 Use the two’s complement number system to represent positive and negative 8-bit binary integers • Convert a positive binary or denary integer to a two’s complement 8-bit integer and vice versa • Convert a negative binary or denary integer to a two’s complement 8-bit integer and vice versa

    来源:剑桥国际大纲

    用二进制计数:0 到 15

    一个数制(number system)是用一组固定的数字书写数字的方式。你需要其中三个。

    系统 基数 使用的数字
    十进制 10 0–9
    二进制 2 0 和 1
    十六进制 16 0–9 然后 A–F
    • 十进制(denary)是正常的计数系统(也叫 decimal)。
    • 二进制(binary)只用 0 和 1。
    • 十六进制(hexadecimal,hex)用十六个数字:0–9,然后 A、B、C、D、E、F 代表 10、11、12、13、14、15。

    基数(base)告诉你一个系统用多少个不同的数字。

    Place value

    一个数中的每一列有一个位值(place value)。在二进制中位值从右到左翻倍。对一个 8 位数它们是:

    128  64  32  16  8  4  2  1
    
    一个 8 位位值图,值从 128 往下到 1,150 的位放在加起来为 150 的列下面
    一个 8 位位值图:1 坐在加起来为 150 的值下面

    一个(bit)是一个单一的 0 或 1。八个位构成一个字节(byte)。四个位(半个字节)是一个半字节(nibble)。

    Converting between number systems

    十进制 → 二进制。 写出位值。在你需要的每个值下面放一个 1,使它们加起来为你的数;在其余的下面放 0。

    例子:把十进制 150 变成二进制。$150 = 128 + 16 + 4 + 2$

    128 64 32 16 8 4 2 1
      1  0  0  1 0 1 1 0
    

    所以 $150$ = 10010110

    二进制 → 十进制。 加上有 1 的位值。10010110 $= 128 + 16 + 4 + 2 = 150$

    十六进制 → 二进制。 把每个十六进制数字变成它自己的 4 位组(一个半字节)。

    例子:十六进制 F08。$F = 1111$,$0 = 0000$,$8 = 1000$,所以 F08 = 1111 0000 1000

    三个十六进制数字 F、0 和 8,每个带一个箭头往下到它自己的一组四个位
    每个十六进制数字映射到它自己的 4 位半字节——F08 = 1111 0000 1000

    二进制 → 十六进制。 把位分成 4 个的半字节,从右边开始。把每个半字节变成一个十六进制数字。

    十进制 → 十六进制。 简单的方式是先变成二进制,然后二进制变成十六进制。

    这个表格帮助记十六进制字母:

    十进制 二进制 十六进制
    10 1010 A
    11 1011 B
    12 1100 C
    13 1101 D
    14 1110 E
    15 1111 F

    Cambridge 的题目用长达 16 位的二进制数。

    例题。 把十进制 100 转换成 8 位二进制,然后转换成十六进制。

    $100 = 64 + 32 + 4$,所以二进制是 01100100。分成半字节,0110 0100 $= 6$$4$,所以十六进制是 64

    Why hexadecimal is used

    十六进制比二进制更短,对人们更容易读和写。一个十六进制数字替换 4 个二进制数字,所以你犯更少的错误。值不改变——十六进制只是显示同样的二进制的一个更短的方式。

    计算机科学家把十六进制用于:

    • MAC 地址和 IPv6 地址
    • HTML 中的颜色代码(例如 #FF0000 是红色)
    • 内存地址(memory addresses)和错误代码
    • 显示内存的内容(一个"内存转储")
    探索

    Binary, denary and hex

    Type a number and see it in binary, denary and hex — and how the place values build it.

    词汇表 训练
    英文 中文 拼音
    number system 数制 shù zhì
    denary 十进制 shí jìn zhì
    hexadecimal 十六进制 shí liù jìn zhì
    base 基数 jī shù
    place value 位值 wèi zhí
    bit wèi
    byte 字节 zì jié
    nibble 半字节 bàn zì jié
    memory address 内存地址 nèi cún dì zhǐ
    1.1

    二进制加法

    你可以把两个 8 位二进制数相加,从右边逐列,就像十进制。一列的规则是:

    A B 结果位 进位
    0 0 0 0
    0 1 1 0
    1 0 1 0
    1 1 0 1

    当一个进位也进来时,$1 + 1 + 1 = 1$ 带一个 1 的进位。

    例子:把 01110110(118)和 00110000(48)相加。

      0 1 1 1 0 1 1 0    (118)
    + 0 0 1 1 0 0 0 0    (48)
    -------------------
      1 0 1 0 0 1 1 0    (166)
    
    118 和 48 的 8 位二进制加法,进位位以红色显示在左列上方,给出 166
    逐列相加;进位向左波动。118 + 48 = 166

    Overflow

    一个 8 位寄存器只能容纳 0 到 255 的十进制值。若一个加法给出一个 255 以上的结果,答案需要一个第 9 位。寄存器不能容纳这个额外的位,所以它丢失了。这叫溢出(overflow,一个溢出错误)。它在一个值超出寄存器能存储的极限时发生。

    例子:11001000(200)$+$ 01001000(72)$= 272$。用二进制那是 1 00010000,它需要 9 位。前导的 1 在 8 位中放不下,所以存储的答案错误。

    把 200 和 72 相加给出 272,它用二进制需要九个位;八位寄存器只保留低的八个而丢失第九位,所以存储的答案是 16 而不是 272
    把 200 和 72 相加需要 9 位,但一个 8 位寄存器丢弃第九个,所以答案错误
    词汇表 训练
    英文 中文 拼音
    overflow 溢出 yì chū
    1.1

    逻辑二进制移位

    一个逻辑二进制移位(logical binary shift)把所有的位左移或右移若干位。

    • 移出寄存器末端的位丢失
    • 被加在空的末端。

    一个左移每移一位把数乘以 2。一个右移每移一位把它除以 2;最右边的位(最低有效位(least significant bit(s)))丢失。

    例子:把 00110101(53)左移 2 位。

    start:         0 0 1 1 0 1 0 1
    left shift 2:  1 1 0 1 0 1 0 0
    
    两位的一个逻辑左移:箭头把每个位往左移两列,最左边的两位丢失,而两个零从右边进入
    2 的一个左移:每个位往左移 2 位,顶部的位丢失,而零填充右边

    结果是 11010100(212),它是 $53 \times 4$。最左边的两位丢失,而两个零从右边进来。若一个 1 被推出末端,那个信息就永远消失了。

    词汇表 训练
    英文 中文 拼音
    logical binary shift 逻辑二进制移位 luó jí èr jìn zhì yí wèi
    least significant bit 最低有效位 zuì dī yǒu xiào wèi
    1.1

    二进制补码

    到目前为止这些数是正的。补码(two's complement)让一个 8 位寄存器也容纳负数。

    在补码中,最左边的位(最高有效位(most significant bit),或 MSB)有一个的位值:

    -128  64  32  16  8  4  2  1
    
    • 若 MSB 是 0,数是正的。
    • 若 MSB 是 1,数是负的。

    要使一个正数变负: 写出正的二进制,翻转每个位(0↔1),然后加 1。

    例子:制造 $-40$

    • $+40$ = 00101000
    • 翻转位 = 11010111
    • 加 1 = 11011000

    所以 $-40$ = 11011000。通过加上位值检查:$-128 + 64 + 16 + 8 = -40$

    一个补码 8 位图,最高有效位值 -128, 被高亮以给出 -40
    最高有效位值 −128,所以 11011000 = −128 + 64 + 16 + 8 = −40

    要读一个负的补码数,只需加上位值(MSB 算作 $-128$)。一个 8 位补码数的范围是 $-128$$+127$

    词汇表 训练
    英文 中文 拼音
    two's complement 补码 bǔ mǎ
    most significant bit 最高有效位 zuì gāo yǒu xiào wèi
    1.2

    文本、声音与图像

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand how and why a computer represents text and the use of character sets, including American standard code for information interchange (ASCII) and Unicode • Text is converted to binary to be processed by a computer • Unicode allows for a greater range of characters and symbols than ASCII, including different languages and emojis • Unicode requires more bits per character than ASCII
    2 Understand how and why a computer represents sound, including the effects of the sample rate and sample resolution • A sound wave is sampled for sound to be converted to binary, which is processed by a computer • The sample rate is the number of samples taken in a second • The sample resolution is the number of bits per sample • The accuracy of the recording and the file size increases as the sample rate and resolution increase
    3 Understand how and why a computer represents an image, including the effects of the resolution and colour depth • An image is a series of pixels that are converted to binary, which is processed by a computer • The resolution is the number of pixels in the image • The colour depth is the number of bits used to represent each colour • The file size and quality of the image increase as the resolution and colour depth increase

    来源:剑桥国际大纲

    计算机通过给每个字符一个数字、然后把那个数字存储为二进制来存储文本。一台计算机能使用的字符集,连同它们的数字,是一个字符集(character set)。

    • ASCII 每个字符用 7 位,所以它有 128 个不同的字符。这对英文字母、数字和常见符号足够了。
    • Unicode 每个字符用更多的位。它能表示多得多的字符——许多语言,加上符号和表情符号(emoji)。

    因为 Unicode 有更多的字符,它每个字符需要比 ASCII 更多的位,所以同样的文本占用更多的存储(storage)。

    ASCII 每个字符用七位用于 128 个字符,对英文足够;Unicode 每个字符用更多的位用于多得多的字符,包括许多语言和表情符号,但占用更多的存储
    ASCII 用 7 位用于 128 个字符;Unicode 用更多的位用于多得多的字符但更多的存储
    词汇表 训练
    英文 中文 拼音
    character set 字符集 zì fú jí
    emoji 表情符号 biǎo qíng fú hào
    storage 存储 cún chǔ
    1.2

    表示声音

    一个声波(sound wave)平滑而一直在变。要存储它,计算机在规律的时刻测量波的高度。这叫采样(sampling),而每次测量是一个样本。

    一个平滑的声波,规律的时间间隔的竖线测量它的高度,标记采样间隔和振幅
    采样在规律的时刻记录波的高度(振幅)
    • 采样率(sample rate)是每秒取的样本的数目(以 Hz 测量)。
    • 采样分辨率(sample resolution)是每个样本使用的位的数目。波在一个采样点的高度是它的振幅(amplitude)。

    一个更高的采样率和一个更高的采样分辨率给一个更准确的录音,但一个更大的文件。

    探索

    Representing sound

    y = a sin(bt + c)

    Sound is a wave; sampling records its height many times a second.

    词汇表 训练
    英文 中文 拼音
    sound wave 声波 shēng bō
    sampling 采样 cǎi yàng
    sample rate 采样率 cǎi yàng lǜ
    sample resolution 采样分辨率 cǎi yàng fēn biàn lǜ
    amplitude 振幅 zhèn fú
    resolution 分辨率 fēn biàn lǜ
    1.2

    表示图像

    一个计算机图像由叫像素(pixels)的小点的一个网格构成。

    一个 8 乘 8 的像素网格,构成一幅简单的彩色图,一个方块被标为一个像素
    一个位图是一个像素网格;分辨率是它有多少像素
    • 分辨率(resolution)是图像中像素的数目(例如 $1920 \times 1080$)。
    • 颜色深度(colour depth)是用来存储每个像素颜色的位的数目。

    一个更高的分辨率和一个更高的颜色深度给一个更好质量的图像,但一个更大的文件。

    词汇表 训练
    英文 中文 拼音
    pixel 像素 xiàng sù
    colour depth 颜色深度 yán sè shēn dù
    1.3

    数据存储与压缩

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand how data storage is measured • Including: – bit – nibble – byte – kibibyte (KiB) – mebibyte (MiB) – gibibyte (GiB) – tebibyte (TiB) – pebibyte (PiB) – exbibyte (EiB) • The amount of the previous denomination present in the data storage size, e.g.: – 8 bits in a byte – 1024 mebibytes in a gibibyte
    2 Calculate the file size of an image file and a sound file, using information given • Answers must be given in the units specified in the question. Calculations must use the measurement of 1024 and not 1000 • Information given may include: – image resolution and colour depth – sound sample rate, resolution and length of track
    3 Understand the purpose of and need for data compression • Compression exists to reduce the size of the file • What the impact of this is, e.g.: – less bandwidth required – less storage space required – shorter transmission time
    4 Understand how files are compressed using lossy and lossless compression methods • Lossy compression reduces the file size by permanently removing data, e.g. reducing resolution or colour depth, reducing sample rate or resolution • Lossless compression reduces the file size without permanent loss of data, e.g. run length encoding (RLE)

    来源:剑桥国际大纲

    数据存储用下面的单位测量。一个半字节是 4 位,一个字节是 8 位;从千字节(KiB)往上,每个单位是它之前的那个的 1024 倍(因为 $1024 = 2^{10}$,它适合二进制)。

    单位 等于
    bit 一个单一的 0 或 1
    nibble 4 位
    byte 8 位
    kibibyte (KiB) 1024 字节
    mebibyte (MiB) 1024 KiB
    gibibyte (GiB) 1024 MiB
    tebibyte (TiB) 1024 GiB
    pebibyte (PiB) 1024 TiB
    exbibyte (EiB) 1024 PiB
    Hard-disk platters: storage is measured in bytes — knowing file size needs width × height × colour depth for images
    Hard-disk platters: storage is measured in bytes — knowing file size needs width × height × colour depth for images
    1.3

    计算文件大小

    图像文件大小(以位计)$=$ 分辨率 $\times$ 颜色深度 $=$$\times$$\times$ 颜色深度。

    例子:一个图像是 $1024 \times 1024$ 像素,颜色深度为 2 字节($= 16$ 位)。

    • $= 1024 \times 1024 \times 16 = 16\,777\,216$
    • 字节 $= \div 8 = 2\,097\,152$ 字节
    • KiB $= \div 1024 = 2048$ KiB
    • MiB $= \div 1024 = 2$ MiB

    声音文件大小(以位计)$=$ 采样率 $\times$ 采样分辨率 $\times$ 以秒计的长度。

    总是除以 1024(不是 1000)以变成 KiB、MiB 等等。以题目要求的单位给出你的答案。

    例题。 一个声音以 8,000 Hz 的采样率、16 位的采样分辨率被录制 30 秒。求以千字节(KiB)计的文件大小。

    • $= 8\,000 \times 16 \times 30 = 3\,840\,000$
    • 字节 $= 3\,840\,000 \div 8 = 480\,000$ 字节
    • KiB $= 480\,000 \div 1024 \approx 469$ KiB
    1.3

    压缩

    压缩(compression)使一个文件更小。一个更小的文件:

    • 使用更少的存储空间,
    • 需要更少的带宽(bandwidth,一个连接能携带的数据量),
    • 花更短的时间发送(一个更短的传输(transmission)时间)。

    有两种类型。

    Lossless compression

    无损(lossless)压缩使文件更小而没有永久损失数据。原始文件能被精确地重建。

    一种方法是行程编码(run-length encoding,RLE)。它用值的一个副本和它重复多少次的一个计数替换一个重复值的行程。例如 WWWWWWWW(8 个白)被存储为"8 W"。这在数据有许多重复时工作得好。

    一条 8 个白然后 4 个红方块的带被压缩成对 8 W 和 4 R
    行程编码把每个行程作为一个计数和一个值存储一次

    Lossy compression

    有损(lossy)压缩通过永久移除一些数据使文件小得多。移除的数据不能取回。例如:

    • 减少一个图像的分辨率或颜色深度,
    • 减少一个声音的采样率或采样分辨率。

    当你必须保留每个细节时(文本和程序文件)用无损。对照片、音乐和视频用有损,那里一个小的质量损失换来一个小得多的文件是值得的。

    探索

    Run-length encoding

    Watch repeated symbols get squashed into a count — simple lossless compression.

    词汇表 训练
    英文 中文 拼音
    compression 压缩 yā suō
    bandwidth 带宽 dài kuān
    transmission 传输 chuán shū
    lossless 无损 wú sǔn
    run-length encoding 行程编码 xíng chéng biān mǎ
    lossy 有损 yǒu sǔn
    1.3

    考试技巧

    • 通过减去位值(128、64、32 …)把十进制 → 二进制转换;通过加上有 1 的位值把二进制 → 十进制转换。
    • 要转换成十六进制,从右边把二进制分成 4 位的半字节;每个半字节恰好是一个十六进制数字。
    • 溢出在一个结果需要比寄存器有的更多的位时发生(一个 8 位寄存器只容纳 0–255),所以额外的位丢失。
    • 以位计的文件大小:对一个图像,宽 × 高 × 颜色深度;对声音,采样率 × 分辨率 × 秒。除以 8 得字节,然后每个更大的单位除以 1024。
    • 无损压缩保留每一位(文本;行程编码);有损永久移除数据(照片、音乐)以获得一个小得多的文件。
  • 2

    数据传输

    讲义 词汇表
    2.1

    什么是数据传输?

    数据传输(data transmission)意味着把数据从一个地方移到另一个——例如从你的计算机到一个网站,或从一部手机到一台打印机。

    数据常常沿一根电缆行进。下面显示两种常见的。

    一根网络电缆的特写,末端是一个带金色金属针脚的透明塑料插头
    一根带 RJ45 插头的 Ethernet 电缆,常用于在一个有线网络上携带数据
    一根被打开以显示里面细玻璃纤维的电缆,带一把尺子作为比例
    一根光纤电缆把数据作为光的脉冲沿细玻璃纤维携带

    在它被发送之前,数据被分解成叫数据包(packets)的小的、相等大小的片。每个数据包分别行进,而它们在另一端被重新组合。

    用数据包有好处:

    • 若一个数据包丢失或损坏,只有那个数据包被再次发送,而不是整个文件;
    • 数据包能走不同的路由,所以一个繁忙或损坏的路由能被避免;
    • 许多用户能同时共享同一个连接。
    词汇表 训练
    英文 中文 拼音
    data transmission 数据传输 shù jù chuán shū
    packets 数据包 shù jù bāo
    2.1

    数据传输的类型与方法

    大纲
    Candidates should be able to: Notes and guidance
    1 (a) Understand that data is broken down into packets to be transmitted
    (b) Describe the structure of a packet • A packet of data contains a: – packet header – payload – trailer • The packet header includes the: – destination address – packet number – originator’s address
    (c) Describe the process of packet switching • Data is broken down into packets • Each packet could take a different route • A router controls the route a packet takes • Packets may arrive out of order • Once the last packet has arrived, packets are reordered
    2 (a) Describe how data is transmitted from one device to another using different methods of data transmission • Including: – serial – parallel – simplex – half-duplex – full-duplex
    (b) Explain the suitability of each method of data transmission, for a given scenario • Including the advantages and disadvantages of each method
    3 Understand the universal serial bus (USB) interface and explain how it is used to transmit data • Including the benefits and drawbacks of the interface

    来源:剑桥国际大纲

    每个数据包有三部分。

    一个数据包显示为三个连接的块——包头、有效载荷和尾部——包头的内容列在它下面
    一个数据包有一个包头、一个有效载荷(数据)和一个尾部;包头携带地址和数据包号
    部分 它容纳什么
    包头(packet header) 控制信息(见下面)
    有效载荷(payload) 被携带的实际数据
    尾部(trailer) 显示数据包在哪里结束,加上一个错误检查

    包头容纳:

    • 发送方的 IP 地址(address,数据包来自哪里),
    • 接收方的 IP 地址(它去哪里),
    • 数据包号(所以数据包能被以正确的顺序重新组合)。
    词汇表 训练
    英文 中文 拼音
    packet header 包头 bāo tóu
    payload 有效载荷 yǒu xiào zài hè
    trailer 尾部 wěi bù
    address 地址 dì zhǐ
    2.1

    分组交换

    数据包交换(packet switching)是数据包在一个网络上被发送的方式。

    两个数据包从一个发送方通过一个路由器网状结构到一个接收方行进,每个走一条不同颜色的路由
    路由器转发数据包,而不同的数据包能走不同的路由到同一个接收方
    • 路由器(routers)的特殊设备读每个数据包的包头并为它选择最好的路由。
    • 每个数据包可能走它自己的路径,所以数据包能以不同的方式行进。
    • 数据包可能乱序到达
    • 当最后一个数据包到达时,数据包用它们的数据包号被重新排序
    探索

    How data travels in packets

    Step through packet switching. Splitting a file into addressed packets is why one lost packet only needs resending, and why many users can share the same line.

    词汇表 训练
    英文 中文 拼音
    packet switching 数据包交换 shù jù bāo jiāo huàn
    routers 路由器 lù yóu qì
    2.1

    数据传输方式

    Serial and parallel

    串行(serial) 并行(parallel)
    如何 一次一位,沿一根导线 一次几位,沿几根导线
    距离 长距离上好 只在短距离上好
    成本 更便宜(更少的导线) 更昂贵(更多的导线)
    错误 位保持顺序 位在长导线上能稍微不同的时间到达

    串行沿一根单一的导线一个接一个地发送位。并行沿几根导线同时发送几位,所以它在短距离上更快。

    串行传输作为一根导线上一行位,和并行传输作为几根导线上一起行进的几位
    串行沿一根导线一次发送一位;并行沿几根导线一次发送几位

    Simplex, half-duplex and full-duplex

    这些描述数据能行进的方向

    两个设备 A 和 B,箭头显示单工(一个方向)、半双工(两个方向一次一个)和全双工(两个方向一次)
    单工只是一个方向;半双工是两个方向但一次一个;全双工是两个方向一次
    方法 方向
    单工(simplex) 只一个方向(例如计算机 → 打印机)
    半双工(half-duplex) 两个方向,但一次只一个(例如对讲机)
    全双工(full-duplex) 同时两个方向(例如电话通话)

    Choosing a method

    选择取决于距离、需要的速度成本,以及数据是否必须同时两个方向行进。

    词汇表 训练
    英文 中文 拼音
    serial 串行 chuàn xíng
    parallel 并行 bìng xíng
    simplex 单工 dān gōng
    half-duplex 半双工 bàn shuāng gōng
    full-duplex 全双工 quán shuāng gōng
    2.1

    USB

    通用串行总线(universal serial bus,USB)是一个把设备连接到一台计算机的常见接口(interface,一个连接点)。

    好处:

    • 同样的连接器被许多设备使用(一个标准);
    • 设备被自动检测,而正确的驱动被加载;
    • 它携带电,所以它能充电或运行一个设备;
    • 连接器只以一种方式插入,所以难以插错。

    缺点:

    • 电缆只能是一个有限的长度(几米);
    • 较旧的 USB 版本比较新的慢;
    • 传输速度能低于一些其他连接类型。
    五个不同的 USB 插头形状并排——micro、mini、type-B 和 type-A——带一个 5 cm 的比例尺
    USB 连接器形状中的几个。全部用同样的 USB 标准,所以设备被自动检测。
    词汇表 训练
    英文 中文 拼音
    universal serial bus 通用串行总线 tōng yòng chuàn xíng zǒng xiàn
    interface 接口 jiē kǒu
    2.2

    差错检测方法

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the need to check for errors after data transmission and how these errors can occur • Errors can occur during data transmission due to interference, e.g. data loss, data gain and data change
    2 Describe the processes involved in each of the following error detection methods for detecting errors in data after transmission: parity check (odd and even), checksum and echo check • Including parity byte and parity block check
    3 Describe how a check digit is used to detect errors in data entry and identify examples of when a check digit is used, including international standard book numbers (ISBN) and bar codes
    4 Describe how an automatic repeat query (ARQ) can be used to establish that data is received without error • Including the use of: – positive/negative acknowledgements – timeout

    来源:剑桥国际大纲

    当数据行进时,干扰(interference)能改变它。三件事能出错:

    • 数据丢失——一些位没有到达;
    • 数据增加——额外的位被加上;
    • 数据改变——一些位被翻转。

    所以接收方检查数据是否正确地到达。

    词汇表 训练
    英文 中文 拼音
    interference 干扰 gān rǎo
    2.2

    错误检测方法

    Parity check

    一个奇偶校验(parity check)给每个字节加一个额外的位,奇偶校验位(parity bit)。有两种类型:

    带四个 1 的数据(偶);一个 0 的奇偶校验位使它保持偶
    一个奇偶校验位被加以使 1 的数目为偶(或奇)
    • 偶校验——字节中 1 的总数(包括奇偶校验位)必须是;
    • 奇校验——1 的总数必须是

    例子(偶校验):数据 1011001 有四个 1,它已经是偶,所以奇偶校验位是 0:

    parity bit + data
        0        1011001
    

    要找到一个错误:接收方数 1。若约定了偶校验但一个字节到达时带数目的 1,一个错误在传输期间发生了。

    一个奇偶校验不能找到每个错误。若两位翻转,计数可能仍看起来正确。

    例题。 一个单一的奇偶校验位告诉你一个错误发生了,但不告诉在哪里。一个奇偶校验块(parity block)能找到确切的位。几个字节一起被发送,每个带一个行奇偶校验位,而底部一个额外的奇偶校验字节(parity byte)为每一列容纳一个奇偶校验位。下面用了偶校验,而一位在传输期间被翻转。找到它。

              b1 b2 b3 b4 b5 | parity
     byte 1    1  0  1  1  0 |   1
     byte 2    0  1  1  0  1 |   1
     byte 3    1  1  1  1  0 |   1    <- row: odd number of 1s
     byte 4    0  0  1  1  0 |   0
     ------------------------------
     parity    0  0  1  1  1 |   1
                     ^ column b3: odd number of 1s
    

    byte 3 打破偶校验,而列 b3 打破偶校验。翻转的位是它们交叉的地方:byte 3, bit b3。把它从 1 改回 0 修复数据。一个单一的奇偶校验位只说一个错误发生了;一个奇偶校验块确切地说在哪里,所以接收方甚至能修复它。

    Checksum

    一个校验和(checksum)是发送前从所有数据算出的一个值。接收方从它收到的数据再次算出校验和。若两个值不匹配,一个错误发生了,而数据被重新发送。

    Echo check

    在一个回送校验(echo check)中,接收方把数据发送回发送方。发送方把它与原始比较。若它们不同,一个错误发生了。(这需要数据被发送两次,所以它慢。)

    Automatic Repeat reQuest (ARQ)

    自动重传请求(Automatic Repeat reQuest,ARQ)用叫确认(acknowledgements)的消息。

    • 若一个数据包正确地到达,接收方发送一个肯定确认;若它没有,发送一个否定确认
    • 发送方启动一个超时(timeout)计时器。若没有肯定确认及时回来,发送方再次发送数据包。

    Check digit

    一个校验码(check digit)是放在一个数末端的一个额外数字,从其他数字算出。它被用来在一个数被键入时找到错误。

    当数被输入时,校验码被再次计算并比较。它能捕捉:

    • 输入了一个不正确的数字,
    • 一个换位错误(transposition error,两个数字被交换,例如 21 被键成 12),
    • 一个数字被遗漏或加了一个额外的数字,
    • 一个语音错误(一个听起来相似的数字,例如 13 和 30)。

    校验码被用于条形码(barcodes)和 ISBN(书号)。

    探索

    Computing concept lab

    Classify concrete examples by the computing idea they demonstrate.

    词汇表 训练
    英文 中文 拼音
    parity check 奇偶校验 jī ǒu jiào yàn
    parity bit 奇偶校验位 jī ǒu jiào yàn wèi
    parity block 奇偶校验块 jī ǒu jiào yàn kuài
    parity byte 奇偶校验字节 jī ǒu jiào yàn zì jié
    checksum 校验和 jiào yàn hé
    echo check 回送校验 huí sòng jiào yàn
    automatic repeat request 自动重传请求 zì dòng zhòng chuán qǐng qiú
    acknowledgements 确认 què rèn
    timeout 超时 chāo shí
    check digit 校验码 jiào yàn mǎ
    transposition error 换位错误 huàn wèi cuò wù
    barcodes 条形码 tiáo xíng mǎ
    2.3

    加密

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the need for and purpose of encryption when transmitting data
    2 Understand how data is encrypted using symmetric and asymmetric encryption • Asymmetric encryption includes the use of public and private keys

    来源:剑桥国际大纲

    Why we need encryption

    加密(encryption)打乱数据,使它在被错误的人拦截(intercepted,捕获)时不能被理解。可读的数据叫明文(plaintext);加密后它变成密文(ciphertext)。

    加密阻止数据被拦截。它只阻止数据被理解。

    Symmetric encryption

    对称加密(symmetric encryption)用一个单一的密钥(key)来加密和解密数据两者。发送方和接收方必须共享这个同样的秘密密钥。风险是密钥本身可能在被共享时被偷。

    Asymmetric encryption

    非对称加密(asymmetric encryption)用两个不同的密钥:

    • 一个任何人都能有的公钥(public key),用来加密;
    • 一个保密的私钥(private key),用来解密。

    用公钥加密的数据只能用匹配的私钥解密,所以密钥从不必被共享。这比共享一个秘密密钥更安全。

    对称加密用一个共享密钥用于两个步骤,和非对称加密用一个公钥加密、一个私钥解密
    对称用一个共享密钥;非对称用一个公钥加密、一个私钥解密
    探索

    The Caesar cipher

    Shift each letter to encrypt a message — the simplest idea of a cipher and its key.

    词汇表 训练
    英文 中文 拼音
    encryption 加密 jiā mì
    intercepted 拦截 lán jié
    plaintext 明文 míng wén
    ciphertext 密文 mì wén
    symmetric encryption 对称加密 duì chèn jiā mì
    key 密钥 mì yào
    asymmetric encryption 非对称加密 fēi duì chèn jiā mì
    public key 公钥 gōng yào
    private key 私钥 sī yào
    2.3

    考试技巧

    • 数据以数据包发送(一个带地址和数据包号的包头、一个有效载荷,和一个尾部)。数据包能走不同的路由并乱序到达,然后由它们的数据包号重新排序。
    • 匹配传输类型:串行(一次一位,长距离上好)对并行(一次几位,短距离);单工 / 半双工 / 全双工描述方向。
    • 一个单一的奇偶校验位只显示一个错误发生了;一个奇偶校验块定位确切的错误位——都失败的那一行和那一列。
    • 学习错误检测方法以及每个做什么:奇偶校验、校验和、回送校验、ARQ,和校验码(用于键入的数)。
    • 对称加密用一个共享密钥;非对称用一个公钥加密、一个私钥解密,所以没有秘密密钥被共享。
  • 3

    硬件

    讲义 词汇表
    3.1

    计算机体系结构

    大纲
    Candidates should be able to: Notes and guidance
    1 (a) Understand the role of the central processing unit (CPU) in a computer • The CPU processes instructions and data that are input into the computer so that the result can be output
    (b) Understand what is meant by a microprocessor • A microprocessor is a type of integrated circuit on a single chip
    2 (a) Understand the purpose of the components in a CPU, in a computer that has a Von Neumann architecture • Including: – units: arithmetic logic unit (ALU) and control unit (CU) – registers: program counter (PC), memory address register (MAR), memory data register (MDR), current instruction register (CIR) and accumulator (ACC) – buses: address bus, data bus and control bus
    (b) Describe the process of the fetch–decode–execute (FDE) cycle, including the role of each component in the process • How instructions and data are fetched from random access memory (RAM) into the CPU, how they are processed using each component and how they are then executed • Storing data and addresses into specific registers • Using buses to transmit data, addresses and signals • Using units to fetch, decode and execute data and instructions
    3 Understand what is meant by a core, cache and clock in a CPU and explain how they can affect the performance of a CPU • The number of cores, size of the cache and speed of the clock can affect the performance of a CPU
    4 Understand the purpose and use of an instruction set for a CPU • An instruction set is a list of all the commands that can be processed by a CPU, and the commands are machine code
    5 Describe the purpose and characteristics of an embedded system and identify devices in which they are commonly used • An embedded system is used to perform a dedicated functions. For example in, domestic appliances, cars, security systems, lighting systems or vending machines. This is different to a general purpose computer that is used to perform many different functions. For example in, a personal computer (PC) or a laptop

    来源:剑桥国际大纲

    取指-译码-执行周期

    中央处理器(central processing unit,CPU)是计算机处理数据并执行指令(instructions)的部分。它通过重复一个周期、每秒数百万次来运行程序。

    一个方形计算机芯片,带一个闪亮的金属顶和印在它上面的型号名
    一个中央处理器(CPU):处理数据并运行指令的芯片

    Parts of the CPU

    部分 它做什么
    算术逻辑单元(arithmetic logic unit,ALU) 做计算(加、减)和逻辑操作(比较)
    控制单元(control unit,CU) 发送控制信号以管理所有部分并告诉它们做什么
    寄存器(registers) 非常小、非常快的存储,一次容纳一份数据

    各部分由总线(buses,携带信息的成组导线)连接:

    • 地址总线(address bus)携带内存地址(一个方向);
    • 数据总线(data bus)携带数据和指令(两个方向);
    • 控制总线(control bus)携带控制信号。
    一个 CPU 的框图,含有控制单元、ALU 和寄存器,由地址、数据和控制总线连到主存
    CPU 容纳控制单元、ALU 和寄存器;三条总线把它连到主存

    Special registers

    这些寄存器在取指-执行周期期间被使用。

    寄存器 目的
    程序计数器(program counter,PC) 容纳下一条指令的地址
    内存地址寄存器(memory address register,MAR) 容纳要读取或写入的地址
    内存数据寄存器(memory data register,MDR) 容纳刚取的数据或指令
    当前指令寄存器(current instruction register,CIR) 容纳现在正被执行的指令
    累加器(accumulator,ACC) 容纳 ALU 计算的结果

    The fetch–execute cycle

    取指执行周期(fetch–execute cycle)有三个阶段,一遍又一遍地重复:

    1. 取指——指令从内存(memory)被复制进 CPU(用 PC、MAR 和 MDR)。PC 随即增加 1。
    2. 译码——控制单元算出指令的意思。
    3. 执行——指令被执行(ALU 可能做一个计算,结果去累加器)。
    取指-译码-执行周期画成三个连接成一个循环的框
    处理器重复三个阶段:取指令、译码它,然后执行它

    Cache memory

    高速缓存(cache)是 CPU 内部或靠近它的少量非常快的内存。它存储 CPU 常用的数据和指令。CPU 从高速缓存读取比从主存快得多,所以计算机运行得更快。

    What affects CPU performance

    特性 效果
    核心(cores)的数目 每个核心能自己运行指令,所以更多的核心能同时做更多的工作
    高速缓存大小 一个更大的高速缓存为 CPU 容纳更多准备好的数据,所以它等得更少
    时钟速度(clock speed) 每秒的周期数;一个更高的时钟速度每秒运行更多的指令

    例题。 两台电脑除以下不同外完全相同:A 是 3.0 GHz 单核 CPU,带 2 MB 缓存;B 是 2.4 GHz 四核 CPU,带 8 MB 缓存。哪一台更适合视频剪辑?为什么?视频剪辑可以拆成许多能同时进行的任务,所以 B 的四个核心可以并行处理多路数据,而 A 一次只能处理一路。B 更大的缓存也把更多常用数据留在离 CPU 很近的地方,所以它需要从 RAM 取数的次数更少。尽管 A 的主频更高,B 仍是更好的选择。不要只凭主频作答:要把核心数、缓存和主频放在一起权衡,并把每一项都联系到具体要做的工作。

    Embedded systems

    一个嵌入式系统(embedded system)是建在一个更大的设备内部做一件固定工作的一台小计算机。它专门用于那个任务,通常小而低成本,而且没有通用操作系统。例子:一台洗衣机、一个微波炉、一个机顶盒。

    探索

    The fetch-execute cycle

    Tap round the loop the CPU repeats billions of times a second — fetch the instruction, decode what it means, execute it, then do it all again.

    词汇表 训练
    英文 中文 拼音
    central processing unit 中央处理器 zhōng yāng chǔ lǐ qì
    instructions 指令 zhǐ lìng
    arithmetic logic unit 算术逻辑单元 suàn shù luó jí dān yuán
    control unit 控制单元 kòng zhì dān yuán
    registers 寄存器 jì cún qì
    buses 总线 zǒng xiàn
    address bus 地址总线 dì zhǐ zǒng xiàn
    data bus 数据总线 shù jù zǒng xiàn
    control bus 控制总线 kòng zhì zǒng xiàn
    program counter 程序计数器 chéng xù jì shù qì
    memory address register 内存地址寄存器 nèi cún dì zhǐ jì cún qì
    memory data register 内存数据寄存器 nèi cún shù jù jì cún qì
    current instruction register 当前指令寄存器 dāng qián zhǐ lìng jì cún qì
    accumulator 累加器 lěi jiā qì
    fetch–execute cycle 取指执行周期 qǔ zhǐ zhí xíng zhōu qī
    Cache 高速缓存 gāo sù huǎn cún
    cores 核心 hé xīn
    clock speed 时钟速度 shí zhōng sù dù
    embedded system 嵌入式系统 qiàn rù shì xì tǒng
    memory 内存 nèi cún
    3.2

    输入与输出设备

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand what is meant by an input device and why it is required • Including: – barcode scanner – digital camera – keyboard – microphone – optical mouse – QR code scanner – touch screen (resistive, capacitive and infra-red) – two-dimensional (2D) and three-dimensional (3D) scanners
    2 Understand what is meant by an output device and why it is required • Including: – actuator – digital light processing (DLP) projector – inkjet printer – laser printer – light emitting diode (LED) screen – liquid crystal display (LCD) projector – liquid crystal display (LCD) screen – speaker – 3D printer
    3 (a) Understand what is meant by a sensor and the purposes of sensors • Limited to: – acoustic – accelerometer – flow – gas – humidity – infra-red – level – light – magnetic field – moisture – pH – pressure – proximity – temperature
    (b) Identify the type of data captured by each sensor and understand when each sensor would be used, including selecting the most suitable sensor for a given context

    来源:剑桥国际大纲

    一个输入设备把数据发送计算机。

    设备 它如何工作
    条形码扫描器(barcode scanner) 向条照光并读取反射回来的图案
    二维码扫描器(QR code scanner) 一个摄像头读取黑白块的一个方形图案
    键盘 按一个键发送那个字符的一个代码
    光电鼠标(optical mouse) 一个光和一个传感器跟踪跨一个表面的移动
    麦克风 把声波变成一个电信号
    数码相机 一个镜头把光聚焦到一个记录像素的传感器上
    传感器(sensors) 测量一个物理量(如温度或光)并把它作为数据发送
    触摸屏(touch screen) 检测你的手指触碰屏幕的地方
    一个黑色计算机键盘的特写,带 QWERTY 字母键
    一个键盘:每次按键发送那个字符的一个代码
    桌上一个白色光电鼠标,下面光电灯发光
    一个光电鼠标:一个光和一个传感器在桌上跟踪它的移动
    一个扁平的白色盒形扫描器,带一个抬起来以扫描一页的关闭的盖子
    一个平板扫描器:它跨一页照光以把它复制进计算机
    一个手持扫描器在一个支架里,由一根 USB 电缆连到一台计算机
    一个条形码扫描器读取条的图案并把它发送给计算机
    一个小的红色数码相机的正面,显示它的镜头和闪光灯
    一个数码相机:一个镜头把光聚焦到一个记录像素的传感器上
    一个手持麦克风,带一个圆形的金属网头
    一个麦克风把声波变成一个电信号
    一个小的蓝黑色温度传感器,在一个带三个针脚的微小电路板上
    一个传感器测量一个物理量(这里是温度)并把它作为数据发送

    一个触摸屏能以三种方式工作:

    • 电阻式(resistive)——两层在你触碰的地方被压在一起;
    • 电容式(capacitive)——它感知你手指的微小电荷;
    • 红外线(infrared)——你的手指打破一个光束的网格。
    一个手指触碰一部智能手机的屏幕以滚动一页
    一个触摸屏感知你的手指触碰它的地方
    探索

    Device and storage lab

    Classify computing examples by what job they do in a system.

    词汇表 训练
    英文 中文 拼音
    barcode scanner 条形码扫描器 tiáo xíng mǎ sǎo miáo qì
    QR code scanner 二维码扫描器 èr wéi mǎ sǎo miáo qì
    sensors 传感器 chuán gǎn qì
    touch screen 触摸屏 chù mō píng
    resistive 电阻式 diàn zǔ shì
    capacitive 电容式 diàn róng shì
    infrared 红外线 hóng wài xiàn
    optical mouse 光电鼠标 guāng diàn shǔ biāo
    3.2

    输出设备

    一个输出设备把数据从计算机发送到用户。

    设备 它如何工作
    执行器(actuator) 把一个电信号变成运动(例如一个马达或阀门)
    LCD/LED 屏幕 用一个微小彩色点的网格显示图像
    投影仪(projector) 把一个放大的图像照到一面墙或屏幕上
    喷墨打印机(inkjet printer) 向纸喷微小的墨滴
    激光打印机(laser printer) 用一个激光和被热固定到纸上的粉末(碳粉)
    3D 打印机 一层一层地构建一个固体物体
    扬声器(speaker) 把一个电信号变成声音
    一个桌面喷墨打印机,顶部的纸盘打开
    一个喷墨打印机向纸喷微小的墨滴
    一个白灰色桌面激光打印机,它的纸盘折出来
    一个激光打印机用一个激光和被热固定到纸上的粉末(碳粉)
    一个 3D 打印机:一个黑色金属框架,握着一个扁平的打印床和一个移动的打印头
    一个 3D 打印机一层一层地构建一个固体物体
    一个圆形支架上的宽的平屏计算机显示器
    一个 LCD/LED 显示器用一个微小彩色点的网格显示图像
    桌上一对小的黑色计算机扬声器
    一个扬声器把一个电信号变成声音
    一对蓝色头戴式耳机
    耳机把一个电信号变成给一个听者的声音
    不同大小的几个电动马达,旁边一个 9 伏电池作为比例
    一个执行器如一个马达把一个电信号变成运动
    词汇表 训练
    英文 中文 拼音
    actuator 执行器 zhí xíng qì
    projector 投影仪 tóu yǐng yí
    inkjet printer 喷墨打印机 pēn mò dǎ yìn jī
    laser printer 激光打印机 jī guāng dǎ yìn jī
    speaker 扬声器 yáng shēng qì
    3.3

    数据存储

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand what is meant by primary storage • Primary storage is directly accessed by the CPU • Including the role of: – random access memory (RAM) – read only memory (ROM) • Including why a computer needs both RAM and ROM, and the difference between them
    2 Understand what is meant by secondary storage • Secondary storage is not directly accessed by the CPU and is necessary for more permanent storage of data
    3 Describe the operation of magnetic, optical and solid-state (flash memory) storage and give examples of each • Magnetic storage uses platters which are divided into tracks and sectors. Data is read and written using electromagnets. Including hard disk drive (HDD) • Optical storage uses lasers to create and read pits and lands. Including: CD, DVD and Blu-ray • Solid-state (flash memory) uses NAND or NOR technology. Transistors are used as control gates and floating gates. Including: solid-state drive (SSD), SD card and USB drive
    4 Describe what is meant by virtual memory, how it is created and used and why it is necessary • Pages of data are transferred between RAM and virtual memory when needed
    5 Understand what is meant by cloud storage • Cloud storage can be accessed remotely in comparison to storing data locally
    6 Explain the advantages and disadvantages of storing data on the cloud in comparison to storing it locally • Physical servers and storage are needed to store data in cloud storage

    来源:剑桥国际大纲

    主存储器(primary storage)是 CPU 能直接使用的内存。有两种。

    RAM:易失性、能改变、容纳运行中的程序。ROM:非易失性、不能改变、容纳启动指令
    RAM 是易失性的并容纳运行中的程序;ROM 是非易失性的且只读
    RAM ROM
    全名 随机存取存储器(random access memory) 只读存储器(read only memory)
    读/写 读和写 只读
    没有电时保留数据? 否——它是易失性(volatile)的 是——它是非易失性(non-volatile)的
    容纳 现在使用中的程序和数据 启动指令(如何引导计算机)

    两者都需要:ROM 告诉计算机如何启动,然后 RAM 容纳你运行的程序。

    一块长而薄的绿色电路板,携带一排排小的黑色内存芯片和一个金色边缘连接器
    一条 RAM(随机存取存储器):它容纳现在使用中的程序和数据
    词汇表 训练
    英文 中文 拼音
    Primary storage 主存储器 zhǔ cún chǔ qì
    random access memory 随机存取存储器 suí jī cún qǔ cún chǔ qì
    read only memory 只读存储器 zhī dú cún chǔ qì
    volatile 易失性 yì shī xìng
    non-volatile 非易失性 fēi yì shī xìng
    3.3

    辅助存储

    辅助存储器(secondary storage)永久地保留数据,即使电关了。它是非易失性的,被用于长期存储。有三种类型。

    类型 它如何存储数据 例子
    磁存储(magnetic storage) 数据作为旋转磁盘上被磁化的斑点存储 硬盘驱动器(HDD)、磁带
    光存储(optical storage) 数据作为被一个激光读取的标记存储 CD、DVD、蓝光
    固态存储(solid state storage) 数据存储在闪存(flash memory)中,没有移动部件 SSD、USB 闪存盘、存储卡
    一个打开的硬盘驱动器内部,显示圆形的银色盘(盘片)和停在它上面的读/写臂
    一个硬盘驱动器(HDD)内部:闪亮的盘旋转,而臂读取被磁化的数据
    四个方形磁带盒,每个容纳一卷细磁带
    磁带把数据存储在一条长磁带上;它对大的备份便宜
    一张闪亮的圆盘,从它的数据表面反射彩虹色
    一张光盘如一张 CD 或 DVD:一个激光读取它闪亮表面上的标记
    一个 2.5 英寸的三星固态驱动器,一个扁平的灰色金属盒,没有可见的移动部件
    一个固态驱动器(SSD)把数据存储在闪存芯片中,没有移动部件
    一个小的白色 U 盘,带一个红色帽环,标注 32 GB
    一个 U 盘把数据存储在闪存中,没有移动部件
    一个金字塔,寄存器在顶部,然后高速缓存,然后 RAM,然后底部辅助存储,带一个更快更小到更慢更大的箭头
    存储构成一个层级:寄存器和高速缓存最快但最小;辅助存储最慢但最大
    探索

    Device and storage lab

    Classify computing examples by what job they do in a system.

    词汇表 训练
    英文 中文 拼音
    Secondary storage 辅助存储器 fǔ zhù cún chǔ qì
    magnetic storage 磁存储 cí cún chǔ
    optical storage 光存储 guāng cún chǔ
    solid state storage 固态存储 gù tài cún chǔ
    flash memory 闪存 shǎn cún
    3.3

    虚拟内存

    当 RAM 变满时,计算机能把辅助存储的一部分用作额外的、假装的 RAM。这叫虚拟内存(virtual memory)。

    现在不需要的数据被从 RAM 移出到磁盘上,这为其他程序在 RAM 中腾出空间。这让你运行比单独的 RAM 能容纳的更多的程序。它更慢,因为辅助存储比 RAM 慢得多。

    RAM 容纳两个活动的程序和一个腾出的槽,一个箭头把一个未使用的程序移出到磁盘
    当 RAM 满时,不使用的数据被移到磁盘以腾出 RAM——更慢,但它让更多的程序运行
    词汇表 训练
    英文 中文 拼音
    virtual memory 虚拟内存 xū nǐ nèi cún
    3.3

    数据存储

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand what is meant by primary storage • Primary storage is directly accessed by the CPU • Including the role of: – random access memory (RAM) – read only memory (ROM) • Including why a computer needs both RAM and ROM, and the difference between them
    2 Understand what is meant by secondary storage • Secondary storage is not directly accessed by the CPU and is necessary for more permanent storage of data
    3 Describe the operation of magnetic, optical and solid-state (flash memory) storage and give examples of each • Magnetic storage uses platters which are divided into tracks and sectors. Data is read and written using electromagnets. Including hard disk drive (HDD) • Optical storage uses lasers to create and read pits and lands. Including: CD, DVD and Blu-ray • Solid-state (flash memory) uses NAND or NOR technology. Transistors are used as control gates and floating gates. Including: solid-state drive (SSD), SD card and USB drive
    4 Describe what is meant by virtual memory, how it is created and used and why it is necessary • Pages of data are transferred between RAM and virtual memory when needed
    5 Understand what is meant by cloud storage • Cloud storage can be accessed remotely in comparison to storing data locally
    6 Explain the advantages and disadvantages of storing data on the cloud in comparison to storing it locally • Physical servers and storage are needed to store data in cloud storage

    来源:剑桥国际大纲

    云存储(cloud storage)把你的数据保存在通过互联网访问的远程物理服务器上,而不是在你自己的设备上。

    • 优点:从任何地方任何设备访问它;没有本地存储硬件要购买或维护;容易分享文件和自动备份。
    • 缺点:需要一个可用的互联网连接;持续的订阅成本;安全和隐私取决于提供商;你依赖那个提供商保持可用和在营。
    Data-centre server racks: cloud storage keeps your files on remote servers you reach over the network
    Data-centre server racks: cloud storage keeps your files on remote servers you reach over the network
    词汇表 训练
    英文 中文 拼音
    Cloud storage 云存储 yún cún chǔ
    3.4

    网络硬件

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand that a computer needs a network interface card (NIC) to access a network
    2 Understand what is meant by, and the purpose of, a media access control (MAC) address, including its structure • A network interface card is given a MAC address at the point of manufacture • MAC addresses are usually written as hexadecimal • MAC addresses are created using the manufacturer code and the serial code
    3 (a) Understand what is meant by, and the purpose of, an internet protocol (IP) address (b) Understand that there are different types of IP address • An IP address is allocated by the network and it can be static or dynamic • Including the characteristics of, and differences between, IPv4 and IPv6
    4 Describe the role of a router in a network • A router sends data to a specific destination on a network • A router can assign IP addresses • A router can connect a local network to the internet

    来源:剑桥国际大纲

    Network interface card (NIC)

    一个网络接口卡(network interface card,NIC)是让一个设备加入一个网络并发送和接收数据的硬件。每个 NIC 有一个内建的 MAC 地址。

    MAC address and IP address

    • 一个 MAC 地址(media access control 介质访问控制 地址)是一个识别一个物理设备的数。制造商设定它,而它通常不改变。它用十六进制书写。
    • 一个 IP 地址(internet protocol 网际协议 地址)是一个识别一个网络上的一个设备的数。它由网络给出并能改变。

    所以一个 MAC 地址随设备,而一个 IP 地址取决于设备正在使用的网络。

    IP 地址有两个版本。IPv4 是 32 位的,写成四个 0–255 的十进制数(例如 192.168.0.1);较新的 IPv6 是 128 位的,写成用冒号分隔的八组十六进制数,提供多得多的地址。一个地址还要么是静态(static)的(固定、手动设置、从不改变),要么是动态(dynamic)的(每次设备连接时由路由器/网络分发,所以能改变)。

    Router

    一个路由器(router)把不同的网络连接在一起——例如,你的家庭网络连到互联网。它读每个数据包中的 IP 地址并把它转发向正确的网络。

    A Wi-Fi router: network hardware forwards packets between devices and the wider Internet
    A Wi-Fi router: network hardware forwards packets between devices and the wider Internet
    探索

    Network route lab

    Follow data from a device through network hardware and protocols.

    词汇表 训练
    英文 中文 拼音
    network interface card 网络接口卡 wǎng luò jiē kǒu kǎ
    static 静态 jìng tài
    dynamic 动态 dòng tài
    router 路由器 lù yóu qì
    fetch-execute cycle 取指执行周期 qǔ zhǐ zhí xíng zhōu qī
    media access control 介质访问控制 jiè zhì fǎng wèn kòng zhì
    internet protocol 网际协议 wǎng jì xié yì
    3.4

    考试技巧

    • 学习取指-译码-执行周期和特殊寄存器:程序计数器容纳下一条指令的地址,MAR/MDR 携带地址/数据,而累加器容纳 ALU 的结果。
    • CPU 性能随更多的核心、一个更大的高速缓存和一个更高的时钟速度改善。
    • RAM 是易失性的(它在没有电时失去它的数据)并容纳使用中的程序;ROM 是非易失性的且只读(启动指令)。
    • 匹配辅助存储类型:(HDD、磁带)、(CD/DVD,被一个激光读取)、固态(SSD、USB、闪存——没有移动部件)。
    • 一个 MAC 地址识别物理设备且通常不改变;一个 IP 地址由网络给出并能改变。
  • 4

    软件

    讲义 词汇表
    4.1

    硬件与软件

    一个计算机系统由一起工作的两部分构成。

    硬件是物理部件(CPU、键盘);软件是程序(应用、OS)
    硬件是物理部件;软件是程序
    • 硬件(hardware)是计算机的物理的(physical)部件——你能触摸的部件。例子:CPU、内存、键盘、屏幕和硬盘。
    • 软件(software)是控制计算机并告诉硬件做什么的程序(programs)。

    硬件自己不能做任何有用的事。软件需要硬件来运行。两者都需要。

    一个计算机主板,带它的芯片、插槽和连接器
    主板和附着到它的部件是硬件——你能触摸的物理部件
    屏幕上一个桌面操作系统
    一个操作系统是软件——告诉硬件做什么的程序
    词汇表 训练
    英文 中文 拼音
    Hardware 硬件 yìng jiàn
    physical 物理的 wù lǐ de
    Software 软件 ruǎn jiàn
    programs 程序 chéng xù
    4.1

    软件类型与中断

    大纲
    Candidates should be able to: Notes and guidance
    1 Describe the difference between system software and application software and provide examples of each • System software provides the services that the computer requires, including operating system and utility software • Application software provides the services that the user requires
    2 Describe the role and basic functions of an operating system • Including: – managing files – handling interrupts – providing an interface – managing peripherals and drivers – managing memory – managing multitasking – providing a platform for running applications – providing system security – managing user accounts
    3 Understand how hardware, firmware and an operating system are required to run applications software • Applications are run on the operating system • The operating system is run on the firmware • The bootloader (firmware) is run on the hardware
    4 Describe the role and operation of interrupts • Including: – how an interrupt is generated – how it is handled using an interrupt service routine – what happens as a result of the interrupts • Software interrupts include division by zero and two processes trying to access the same memory location • Hardware interrupts include pressing a key on the keyboard and moving the mouse

    来源:剑桥国际大纲

    软件分成两种类型。

    一棵树,把软件分成系统软件(操作系统、实用程序、驱动、编译器)和应用软件(文字处理器、电子表格、数据库、浏览器)
    软件划分成系统软件(运行计算机)和应用软件(让用户做一个任务)

    System software

    系统软件(system software)控制计算机本身并给其他程序一个运行的基础。例子:

    • 操作系统(operating system,见下面);
    • 编译器(compiler)和链接器(linker,把程序变成计算机能运行的一个形式的工具);
    • 设备驱动程序(device driver)——让操作系统控制一件硬件的软件;
    • 实用程序(utility software)——照料计算机的小工具(例如防病毒、备份、磁盘清理)。

    操作系统之下是固件(firmware)——永久存储在 ROM 或闪存上、计算机一开机就运行的软件。BIOS引导程序(bootloader)就是固件:它们测试硬件然后加载操作系统。所以各层堆叠成硬件 → 固件 → 操作系统 → 应用软件,每一层都在它下面的层上运行。

    Application software

    应用软件(application software)让用户做一个有用的任务。例子:

    • 文字处理(word processing)软件(写文档);
    • 电子表格(spreadsheet)软件(在一个网格中处理数字);
    • 数据库管理系统(database management system,存储和搜索数据);
    • 网页浏览器(web browser,查看网页)。
    系统软件 应用软件
    工作 运行和管理计算机 帮助用户做一个任务
    被谁使用 计算机(在后台) 用户(直接)
    例子 操作系统、驱动、实用程序 文字处理器、浏览器、游戏
    词汇表 训练
    英文 中文 拼音
    System software 系统软件 xì tǒng ruǎn jiàn
    operating system 操作系统 cāo zuò xì tǒng
    linker 链接器 liàn jiē qì
    device driver 设备驱动程序 shè bèi qū dòng chéng xù
    utility software 实用程序 shí yòng chéng xù
    firmware 固件 gù jiàn
    bootloader 引导程序 yǐn dǎo chéng xù
    Application software 应用软件 yìng yòng ruǎn jiàn
    word processing 文字处理 wén zì chǔ lǐ
    spreadsheet 电子表格 diàn zi biǎo gé
    database management system 数据库管理系统 shù jù kù guǎn lǐ xì tǒng
    web browser 网页浏览器 wǎng yè liú lǎn qì
    providing a user interface 用户界面 yòng hù jiè miàn
    managing peripherals 外围设备 wài wéi shè bèi
    managing multitasking 多任务处理 duō rèn wù chǔ lǐ
    providing a platform 平台 píng tái
    4.1

    操作系统

    一个操作系统(OS)是主要的系统软件。它控制整个计算机并让硬件、应用软件和用户一起工作。没有一个 OS,计算机很难使用。

    四个堆叠的层——用户在顶部,然后应用软件,然后操作系统,然后底部硬件
    操作系统坐在硬件和应用软件及用户之间,让它们一起工作

    OS 有许多作用:

    • 管理文件——保存、打开、命名、移动和删除文件;
    • 处理中断(见下面);
    • 提供一个用户界面(user interface),所以用户能控制计算机;
    • 管理内存——决定 RAM 中保留什么、在哪里;
    • 管理外围设备(peripherals)及它们的驱动——控制像打印机的设备;
    • 管理多任务处理(multitasking)——让几个程序一次运行;
    • 提供一个平台(platform)用于运行应用软件;
    • 管理安全——用户账户、密码和访问权限。
    词汇表 训练
    英文 中文 拼音
    user interface 用户界面 yòng hù jiè miàn
    peripherals 外围设备 wài wéi shè bèi
    multitasking 多任务处理 duō rèn wù chǔ lǐ
    platform 平台 píng tái
    4.1

    中断

    一个中断(interrupt)是发送给处理器(processor)的一个信号,告诉它某样东西现在需要注意。

    一个中断能来自三个来源:

    • 硬件——例如一个键被按下,或一台打印机用完纸;
    • 软件——例如一个程序试图除以零;
    • 用户——例如用户按一个"取消"键。

    当一个中断到达时,处理器停止它正在做的事、保存它的位置,并服务(处理)中断。当那完成时,它回到它之前正在做的事。这让计算机对重要的事件快速反应。

    一个循环:主程序运行,然后在一个中断上 CPU 保存它的状态、运行中断服务例程、恢复状态并恢复运行
    在一个中断上 CPU 保存它的位置、运行中断服务例程,然后恢复它的位置并继续
    探索

    How the CPU handles an interrupt

    Step through an interrupt. The CPU pauses what it's doing, deals with the urgent event, then carries on exactly where it left off — which is how one processor juggles the keyboard, printer and timer at once.

    词汇表 训练
    英文 中文 拼音
    interrupt 中断 zhōng duàn
    processor 处理器 chǔ lǐ qì
    4.2

    编程语言类型、翻译程序与集成开发环境(IDE) (IDEs)

    大纲
    Candidates should be able to: Notes and guidance
    1 Explain what is meant by a high-level language and a low-level language, including the advantages and disadvantages of each • Advantages and disadvantages include: – ease of reading and writing code, e.g. low-level is hard to read – ease of debugging code – machine independence – direct manipulation of hardware
    2 Understand that assembly language is a form of low-level language that uses mnemonics, and that an assembler is needed to translate an assembly language program into machine code
    3 Describe the operation of a compiler and an interpreter, including how high-level language is translated by each and how errors are reported • A compiler translates the whole code at once before executing it, producing an executable file • An interpreter translates and executes the code line-by-line • A compiler provides an error report for the whole code if errors are detected • An interpreter stops execution when an error is found
    4 Explain the advantages and disadvantages of a compiler and an interpreter • Including an understanding that an interpreter is mostly used when developing a program and a compiler is used to translate the final program
    5 Explain the role of an IDE in writing program code and the common functions IDEs provide • Including: – code editors – run-time environment – translators – error diagnostics – auto-completion – auto-correction – prettyprint

    来源:剑桥国际大纲

    所有计算机用中央处理器(central processing unit,CPU)处理数据。要使 CPU 做工作,人们用一门编程语言(programming language)写程序。有两种。

    High-level languages

    一门高级语言(high-level language)用看起来有点像英语的词书写(例如 Python)。它是:

    • 对人们容易读、写和修复;
    • 独立于计算机——同一个程序能在不同类型的计算机上运行。

    Low-level languages

    一门低级语言(low-level language)接近硬件实际使用的。它包括:

    • 机器码(machine code)——用二进制(0 和 1)书写的指令,CPU 直接运行它;
    • 汇编语言(assembly language)——用短的词代码(助记符)而不是二进制书写的机器码。

    一门低级语言与特定的(specific)类型的 CPU 相关,所以为一个 CPU 写的程序可能不在另一个上运行。它在程序员需要对硬件的完全控制或非常快、小的代码时使用。

    三个堆叠的层:高级语言在顶部,然后汇编,然后底部机器码
    高级语言接近人类语言并在任何计算机上运行;低级语言(汇编和机器码)接近硬件并绑定到一种类型的 CPU
    探索

    Computing concept lab

    Classify concrete examples by the computing idea they demonstrate.

    词汇表 训练
    英文 中文 拼音
    central processing unit 中央处理器 zhōng yāng chǔ lǐ qì
    programming language 编程语言 biān chéng yǔ yán
    high-level language 高级语言 gāo jí yǔ yán
    low-level language 低级语言 dī jí yǔ yán
    machine code 机器码 jī qì mǎ
    assembly language 汇编语言 huì biān yǔ yán
    specific 特定的 tè dìng de
    4.2

    翻译程序

    CPU 只能运行机器码。一个高级程序必须先被变成机器码。做这个的软件是一个翻译程序(translator)。有三种类型:编译器和解释器(用于高级代码),以及汇编器(用于低级代码)。

    Compiler

    一个编译器在程序被运行之前整个程序翻译成机器码。翻译之后,机器码能被运行许多次而不再翻译。

    • 翻译一次性发生,完整地;
    • 它在翻译结束时一起报告所有的错误;
    • 完成的程序运行快,而且不需要编译器来运行。

    Interpreter

    一个解释器(interpreter)一次一行地翻译并运行程序。

    • 它在它找到的第一个错误停止,这在测试时有帮助;
    • 程序运行更慢,因为它每次运行都被翻译;
    • 每次程序运行时解释器都必须在场。
    编译器 解释器
    翻译 整个程序一次 一次一行
    错误 全部在结束时报告 在第一个错误停止
    完成程序的速度 更快 更慢
    以后运行需要?

    当你想分享一个快速的、完成的程序时用一个编译器。当你在写和测试一个程序、想容易地找到错误时用一个解释器

    Assembler

    一个汇编器(assembler)把一个低级汇编语言程序(用像 LDAADD 这样的助记符写成)翻译成机器码。每个助记符变成一条机器指令——一个直接的一对一翻译,不像处理高级代码的编译器或解释器。

    编译器把整个程序一次翻译成运行许多次的机器码,对一个解释器一次一行地翻译并运行
    一个编译器把整个程序一次翻译成机器码;一个解释器一次一行地翻译并运行

    例题。 一个团队正在编写程序。开发期间他们希望快速找到并修复错误;发布时他们希望客户运行得快,并且看不到源代码。每个阶段各适合哪种翻译器?开发时用解释器:它一次翻译并运行一行,遇到第一个错误就停下,所以错误很容易定位。发布时用编译器:它把整个程序一次性翻译成机器码,之后无需翻译器就能快速运行,而且客户拿到的只是可执行文件,不是源代码。两者不是对手 - 要说出阶段并给出理由,因为只写"编译器更快"是得不到分的。

    词汇表 训练
    英文 中文 拼音
    compiler 编译器 biān yì qì
    translator 翻译程序 fān yì chéng xù
    interpreter 解释器 jiě shì qì
    assembler 汇编器 huì biān qì
    4.2

    集成开发环境(IDE)

    一个集成开发环境(integrated development environment,IDE)是帮助你写程序的软件。它把许多有用的工具放在一个地方:

    • 一个代码编辑器(code editor)——用于键入你的程序;
    • 一个运行时环境(run time environment)——用于运行程序以测试它;
    • 一个翻译程序(translator)——一个编译器或解释器把你的代码变成机器码;
    • 错误诊断(error diagnostics)——帮助你找到并理解错误的消息;
    • 自动补全(auto-completion)和自动纠错(auto-correction)——IDE 在你键入时完成或修复代码;
    • 美化打印(prettyprinting)——用颜色和缩进整齐地布置代码,使它容易阅读。
    Source code in an editor: an IDE combines editor, debugger and run tools in one place
    Source code in an editor: an IDE combines editor, debugger and run tools in one place
    词汇表 训练
    英文 中文 拼音
    integrated development environment 集成开发环境 jí chéng kāi fā huán jìng
    code editor 代码编辑器 dài mǎ biān jí qì
    run time environment 运行时环境 yùn xíng shí huán jìng
    error diagnostics 错误诊断 cuò wù zhěn duàn
    auto-completion 自动补全 zì dòng bǔ quán
    auto-correction 自动纠错 zì dòng jiū cuò
    prettyprinting 美化打印 měi huà dǎ yìn
    4.2

    考试技巧

    • 硬件是物理部件;软件是程序。系统软件运行计算机(OS、驱动、实用程序);应用软件为用户做一个任务。
    • 一个编译器把整个程序一次翻译(完成的程序运行快,而所有错误在结束时报告);一个解释器逐行翻译(它在第一个错误停止、运行更慢,而且每次都需要)。
    • 高级语言接近英语并在任何计算机上运行;低级语言(汇编、机器码)绑定到一种类型的 CPU。
    • 一个中断是使 CPU 停止、保存它的位置、服务事件,然后在它离开的地方继续的一个信号。
    • 学习操作系统的作用:管理文件、内存、外围设备、多任务处理、安全和用户界面。
  • 5

    互联网及其应用

    讲义 词汇表
    5.1

    互联网与万维网

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the difference between the internet and the world wide web • The internet is the infrastructure • The world wide web is the collection of websites and web pages accessed using the internet
    2 Understand what is meant by a uniform resource locator (URL) • A URL is a text-based address for a web page; it can contain the protocol, the domain name and the web page/file name
    3 Describe the purpose and operation of hypertext transfer protocol (HTTP) and hypertext transfer protocol secure (HTTPS)
    4 Explain the purpose and functions of a web browser • The main purpose of a web browser is to render hypertext markup language (HTML) and display web pages • Functions include: – storing bookmarks and favourites – recording user history – allowing use of multiple tabs – storing cookies – providing navigation tools – providing an address bar
    5 Describe how web pages are located, retrieved and displayed on a device when a user enters a URL • Including the role of: – the web browser – IP addresses – the domain name server (DNS) – the web server – HTML
    6 Explain what is meant by cookies and how they are used, including session cookies and persistent cookies • Cookies are used for functions, including: – saving personal details – tracking user preferences – holding items in an online shopping cart – storing login details

    来源:剑桥国际大纲

    人们常常混淆这两个术语,但它们不相同。

    • 互联网(internet)是基础设施(infrastructure)——巨大的全球计算机网络以及连接它们的电缆、路由器和连接。
    • 万维网(world wide web,WWW)是你用互联网查看的网站(websites)和网页的一个集合。

    所以互联网是网络;网是你在那个网络使用的东西之一。

    一个标注为互联网的大框,含有两个更小的框:万维网,和其他服务如电子邮件
    互联网是全球网络;万维网是你在它上面使用的东西之一
    一个黑色盒形路由器,三根高天线从它竖起
    一个路由器把你的家庭网络连到互联网并把数据发送到正确的地方
    词汇表 训练
    英文 中文 拼音
    internet 互联网 hù lián wǎng
    infrastructure 基础设施 jī chǔ shè shī
    world wide web 万维网 wàn wéi wǎng
    websites 网站 wǎng zhàn
    5.1

    URL

    一个统一资源定位符(uniform resource locator,URL)是一个网页的一个基于文本的地址。你把它键入一个网页浏览器(web browser)以访问一个页面,例如 https://www.example.com/index.html

    URL https://www.example.com/index.html 分成三个标注的部分:协议、域名和路径
    一个 URL 有三部分:协议、域名,和到服务器上页面的路径
    词汇表 训练
    英文 中文 拼音
    uniform resource locator 统一资源定位符 tǒng yī zī yuán dìng wèi fú
    web browser 网页浏览器 wǎng yè liú lǎn qì
    5.1

    网页浏览器

    一个网页浏览器是你用来查看网页的程序。它的作用包括:

    • 渲染(rendering)超文本标记语言(hypertext markup language,HTML)——把页面的代码变成你看到的;
    • 在屏幕上显示网页;
    • 管理一个网页如何呈现——它的布局、文本和图像。
    词汇表 训练
    英文 中文 拼音
    rendering 渲染 xuàn rǎn
    hypertext markup language 超文本标记语言 chāo wén běn biāo jì yǔ yán
    IP address 网际协议地址 wǎng jì xié yì dì zhǐ
    5.1

    网页如何到达你的设备

    当你键入一个 URL 并按回车时,几个步骤发生:

    1. 浏览器需要网站的 IP 地址(网际协议地址),但一个 URL 用一个名称,而不是一个数。
    2. 浏览器询问一个域名服务(domain name service,DNS)——一个存储每个网址 IP 地址的系统。
    3. DNS 找到匹配的 IP 地址并把它发送回浏览器。
    4. 浏览器用 IP 地址联系存储页面的网页服务器(web server)。
    5. 网络服务器把页面的 HTML 发送回浏览器。
    6. 浏览器把 HTML 变成页面并显示它。
    浏览器向一个 DNS 服务器询问一个 IP 地址,然后从网络服务器请求页面并收到 HTML
    浏览器向一个 DNS 询问网站的 IP 地址,然后从网络服务器请求页面,它返回 HTML

    若 DNS 没有这个地址,它询问另一个 DNS 服务器,直到地址被找到。

    一个数据中心里,金属机架里一长排排计算机服务器,被蓝色灯照亮
    一个满是服务器的数据中心:存储网站并把它们发送给你的强大计算机

    例题。 分解网址 https://www.example.com/books/index.htmlhttps协议,即传输该网页所用的一套规则(其中的 s 表示传输是加密的)。www.example.com域名,它标识这台网页服务器,并由 DNS 服务器把它转换成 IP 地址。/books/index.html 是该服务器上所存资源的文件路径和文件名。要把每一部分连同它的作用一起说出来:只答"第一段"和"最后一段"是在描述网址,而不是在解释它。

    探索

    What happens when you load a web page

    Step through it. The web address is just a name — DNS turns it into an IP address before the browser can ask the right server for the page.

    词汇表 训练
    英文 中文 拼音
    domain name service 域名服务 yù míng fú wù
    web server 网页服务器 wǎng yè fú wù qì
    5.1

    Cookie

    一个 cookie 是一个网站存储在你设备上的一个小文本文件。它让网站记住关于你的东西。有两种类型。

    一个 cookie 是一个小文本文件,存储在你的计算机上,它记住你的设置或登录
    一个 cookie 是一个存储在你计算机上的小文本文件
    类型 你关闭浏览器时保留? 用于
    会话(session)cookie 否——你关闭浏览器时被删除 短期数据,例如一个购物篮中的物品
    持久(persistent)cookie 是——保存在设备上 在访问之间记住你

    Cookie 被用来:

    • 保存个人详细信息,所以你不再键入它们(如登录或地址);
    • 跟踪用户偏好(user preferences),如你的语言或你喜欢的东西,所以网站能建议内容。
    词汇表 训练
    英文 中文 拼音
    session 会话 huì huà
    persistent 持久 chí jiǔ
    user preferences 用户偏好 yòng hù piān hǎo
    5.2

    数字货币

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the concept of a digital currency and how digital currencies are used • A digital currency is one that only exists electronically
    2 Understand the process of blockchain and how it is used to track digital currency transactions • Blockchain, in its basic form, is a digital ledger, that is a time-stamped series of records that cannot be altered

    来源:剑桥国际大纲

    一个数字货币(digital currency)是只以电子形式(electronic form)存在的钱。没有硬币或纸币。它用计算机在人们之间存储和移动,并能被用来在线为东西付款。

    数字钱的一个问题是信任:你如何阻止某人把同样的钱花两次,或改变记录?区块链解决这个。

    词汇表 训练
    英文 中文 拼音
    digital currency 数字货币 shù zì huò bì
    electronic form 电子形式 diàn zi xíng shì
    5.2

    区块链

    一个区块链(blockchain)是一个数字账本(digital ledger)——每个交易(transaction)的一个共享记录。这个记录被复制到许多计算机上,所以没有单个人控制它,而且它很难改变。

    交易被保存在连接成一条链的块中。每个块容纳:

    • 交易的数据(谁付谁,以及多少);
    • 一个时间戳(timestamp,日期和时间);
    • 一个哈希值(hash value)——从块的内容算出的一个特殊代码。

    每个块也存储它之前的块的哈希。若某人改变一个旧块,它的哈希改变,所以它不再匹配下一个块。这打破链,而改变立即被发现。这就是区块链如何安全地跟踪交易。

    一条链中的三个块,每个容纳数据、一个时间戳和一个哈希,每个块也存储前一个块的哈希
    每个块存储前一个块的哈希,把块链接起来;改变一个块打破链
    探索

    Hashing behind a blockchain

    A hash is one-way and a tiny change to the input flips much of the output — a blockchain chains these hashes so any tamper is obvious.

    词汇表 训练
    英文 中文 拼音
    blockchain 区块链 qū kuài liàn
    digital ledger 数字账本 shù zì zhàng běn
    transaction 交易 jiāo yì
    timestamp 时间戳 shí jiān chuō
    hash value 哈希值 hā xī zhí
    5.3

    网络安全

    大纲
    Candidates should be able to: Notes and guidance
    1 Describe the processes involved in, and the aim of carrying out, a range of cyber security threats • Including: – brute-force attack – data interception – distributed denial of service (DDoS) attack – hacking – malware (virus, worm, Trojan horse, spyware, adware, ransomware) – pharming – phishing – social engineering
    2 Explain how a range of solutions are used to help keep data safe from security threats • Including: – access levels – anti-malware, including anti-virus and anti-spyware – authentication (username and password, biometrics, two-step verification) – automating software updates – checking the spelling and tone of communications – checking the URL attached to a link – firewalls – privacy settings – proxy-servers – secure socket layer (SSL) security protocol

    来源:剑桥国际大纲

    网络安全(cyber security)意味着保持计算机、网络和数据免于攻击。你必须知道这些威胁。

    威胁 它是什么
    暴力破解(brute force attack) 非常快地尝试许多密码直到正确的被找到
    数据拦截(data interception) 在数据跨一个网络行进时"偷听"以窃取数据
    分布式拒绝服务(distributed denial of service,DDoS)攻击 用如此多的请求淹没一个服务器,使它不能响应,所以网站宕机
    黑客攻击(hacking) 未经许可获得对一个计算机系统的访问
    恶意软件(malware) 有害的软件(见下面的表格)
    域名欺骗(pharming) 秘密代码即使在你键入正确的地址时也把你送到一个假网站
    网络钓鱼(phishing) 欺骗你交出私密详细信息的假邮件或消息
    社会工程(social engineering) 欺骗一个人(而不是一台计算机)去破坏安全,例如假装是老板

    Types of malware

    恶意软件是任何制造来伤害一台计算机的软件。主要的类型是:

    恶意软件 它做什么
    病毒(virus) 附着到一个文件并在文件被打开时复制自己;能删除或损坏数据
    蠕虫(worm) 自己跨一个网络复制自己,而不需要一个文件被打开
    特洛伊木马(Trojan horse) 假装是有用的软件,但一旦安装就伤害计算机
    间谍软件(spyware) 秘密地记录你做什么,如你按的键
    广告软件(adware) 用不需要的广告淹没你
    勒索软件(ransomware) 锁住你的文件并要求付款来解锁它们

    Impact of the threats

    这些攻击能窃取个人数据删除或改变文件阻止一个服务工作、花钱,并使用户失去对一个公司的信任。例如,一个 DDoS 攻击能使一个在线商店不可用,所以它失去销售。

    A padlock: cyber security locks data and systems against malware, phishing and unauthorised access
    A padlock: cyber security locks data and systems against malware, phishing and unauthorised access
    词汇表 训练
    英文 中文 拼音
    cyber security 网络安全 wǎng luò ān quán
    brute force attack 暴力破解 bào lì pò jiě
    data interception 数据拦截 shù jù lán jié
    distributed denial of service 分布式拒绝服务 fēn bù shì jù jué fú wù
    hacking 黑客攻击 hēi kè gōng jī
    malware 恶意软件 è yì ruǎn jiàn
    pharming 域名欺骗 yù míng qī piàn
    phishing 网络钓鱼 wǎng luò diào yú
    social engineering 社会工程 shè huì gōng chéng
    virus 病毒 bìng dú
    worm 蠕虫 rú chóng
    Trojan horse 特洛伊木马 tè luò yī mù mǎ
    spyware 间谍软件 jiàn dié ruǎn jiàn
    adware 广告软件 guǎng gào ruǎn jiàn
    ransomware 勒索软件 lè suǒ ruǎn jiàn
    5.3

    保护数据安全

    你可以用这些方法保护数据。

    • 访问权限(access levels)——每个用户只能看或改变他们需要的数据,不多。
    • 反恶意软件(anti-malware)软件,包括杀毒软件(anti-virus)和反间谍软件(anti-spyware)——扫描并移除有害的软件。
    • 身份验证(authentication)——在你获得访问之前证明你是谁。方法包括:
      • 生物识别(biometrics,指纹或面部),
      • 一个密码(password),
      • 两步验证(two-step verification,一个发到你手机的代码加上一个密码)。
    • 自动化软件更新——更新自动地修复软件中的弱点(漏洞)。
    • 检查消息的拼写和语气——糟糕的拼写或一个奇怪、紧急的语气能显示一个消息是假的(网络钓鱼)。
    • 检查附着到一个链接的 URL——一个错误或奇怪的网址警告你链接不安全。
    • 防火墙(firewall)——检查进出一个网络的数据并阻挡任何不被允许的东西。
    • 隐私设置(privacy settings)——控制谁能在线看到你的信息。
    互联网和一个私有网络之间的一个防火墙,让一个被允许的连接通过并阻挡另一个
    一个防火墙坐在外部互联网和你的网络之间,检查每个连接并阻挡任何不被允许的流量
    • 代理服务器(proxy server)——坐在用户和互联网之间,隐藏用户的 IP 地址并过滤掉不安全的内容。
    探索

    Encryption with a key

    Change the shift — that is the key. Each letter slides that many places to make ciphertext, and the same key slides it back. That is symmetric encryption.

    词汇表 训练
    英文 中文 拼音
    access levels 访问权限 fǎng wèn quán xiàn
    anti-malware 反恶意软件 fǎn è yì ruǎn jiàn
    anti-virus 杀毒软件 shā dú ruǎn jiàn
    anti-spyware 反间谍软件 fǎn jiàn dié ruǎn jiàn
    authentication 身份验证 shēn fèn yàn zhèng
    biometrics 生物识别 shēng wù shí bié
    password 密码 mì mǎ
    two-step verification 两步验证 liǎng bù yàn zhèng
    firewall 防火墙 fáng huǒ qiáng
    privacy settings 隐私设置 yǐn sī shè zhì
    proxy server 代理服务器 dài lǐ fú wù qì
    5.3

    考试技巧

    • 互联网是全球网络(基础设施);万维网是你在它上面查看的页面——不要混淆这两个。
    • 学习一个页面如何加载:浏览器向一个 DNS 询问网站的 IP 地址,然后从网络服务器请求页面,它返回 HTML。
    • 匹配恶意软件类型:病毒(附着到一个文件)、蠕虫(自己跨一个网络传播)、特洛伊木马(假装有用)、间谍软件勒索软件
    • 把每个威胁匹配到一个防御:网络钓鱼/域名欺骗 → 检查 URL;暴力破解 → 强密码 + 两步验证;拦截 → 加密;黑客攻击/DDoS → 一个防火墙。
    • 一个会话 cookie 在你关闭浏览器时被删除;一个持久 cookie 被保存以在访问之间记住你。
  • 6

    自动化与新兴技术

    讲义 词汇表
    6.1

    自动化系统

    大纲
    Candidates should be able to: Notes and guidance
    1 Describe how sensors, microprocessors and actuators can be used in collaboration to create automated systems
    2 Describe the advantages and disadvantages of an automated system used for a given scenario • Including scenarios from: – industry – transport – agriculture – weather – gaming – lighting – science

    来源:剑桥国际大纲

    一个自动化系统(automated system)是软件和硬件的一个混合,它感知并响应它环境(environment)中的数据,不需要人工干预(human intervention)。换句话说,它自己工作。

    自动化系统的例子:

    • 一个中央供暖(central heating)系统;
    • 一个工厂里的化学过程(chemical process);
    • 一个温室(greenhouse,用于种植植物);
    • 一个停车场道闸(car park barrier)。

    Sensors, microprocessors and actuators

    三个部分在一个自动化系统中一起工作。

    部分 工作
    传感器(sensor) 测量一个物理量(如温度或光)并发送数据
    微处理器(microprocessor) 把数据与存储值比较并做决定
    执行器(actuator) 接收一个信号并引起运动或动作(如打开一个阀门)

    循环像这样工作:

    1. 传感器把数据发送给微处理器。
    2. 微处理器把这个数据与存储值(stored values)比较并做一个决定。
    3. 微处理器把信号发送给执行器以采取行动。

    例如,在一个温室里:一个温度传感器读取热;微处理器把它与想要的值比较;若太热,微处理器给一个执行器发信号以打开一扇窗。

    一个循环:一个温度传感器馈送微处理器,它给一个执行器发信号以打开一扇窗、给温室降温,传感器随后再次测量它
    一个传感器馈送微处理器,它把读数与一个存储值比较并给一个执行器发信号;然后循环重复

    考纲点名许多传感器类型(sensor types),每个读一个物理量——例如一个加速度计(accelerometer)(运动或倾斜)、一个湿度(humidity)传感器(空气中的水),和一个接近(proximity)传感器(附近的物体):

    Sensor Measures Typical use
    temperature heat ovens, greenhouses, heating
    light brightness automatic lights, cameras
    pressure force on a surface alarm floor mats, touchscreens
    infra-red / proximity a nearby object automatic doors, parking sensors
    acoustic (sound) sound level noise monitors
    humidity / moisture water in air or soil greenhouses, irrigation
    gas a gas being present smoke and CO alarms
    pH acidity pools, fish tanks
    accelerometer movement or tilt phones, airbag triggers
    magnetic field magnetism door contacts, compasses
    flow / level fluid flow or depth pipes, tanks

    给一个场景挑传感器,选读正确物理量的那个:一个鱼缸需要 pH 和温度传感器;一扇自动门需要一个红外/接近传感器。

    Advantages and disadvantages

    自动化系统被用于许多情况,如工业、运输、农业(agriculture,种田)、天气(收集数据)、游戏和照明。

    自动化系统的优点,如全天候工作和一致性,对缺点,如高的建立成本和失去的工作
    自动化系统的优点和缺点
    一个白色的四旋翼无人机,带一个小摄像头,在海上空的天空中飞行
    一个摄像头无人机:它能自己沿一条设定的路线飞行以收集数据
    优点 缺点
    全天全夜工作,不休息 购买和建立花费很多
    比人更快、更一致(consistent) 能出故障并需要专家修理
    能在对人不安全的地方工作 可能替换人们的工作
    更少的人为错误 不能容易地对一个它们不是为之建造的情况作出反应

    例题。 描述一个自动温室如何把温度保持在 25 °C。温度传感器持续测量温度,读数经模数转换器转成数字后送给微处理器。微处理器把读数与存储的 25 °C 这个值进行比较。如果温度高于它,微处理器就给执行器发信号,打开窗户或启动风扇;如果低于它,就打开加热器。然后整个回路不断重复。有两分几乎总是落在"与存储的(预设的)值比较"和"该过程重复进行"这两句话上 - 只写到"传感器告诉计算机"就停下的描述会丢掉它们。

    探索

    An automated control loop

    Tap round the loop. An automated system senses, compares against a target, then acts — and because the action changes what it senses, it keeps correcting itself with no human needed.

    词汇表 训练
    英文 中文 拼音
    automated system 自动化系统 zì dòng huà xì tǒng
    environment 环境 huán jìng
    human intervention 人工干预 rén gōng gān yù
    greenhouse 温室 wēn shì
    car park barrier 停车场道闸 tíng chē chǎng dào zhá
    sensor 传感器 chuán gǎn qì
    microprocessor 微处理器 wēi chǔ lǐ qì
    actuator 执行器 zhí xíng qì
    stored values 存储值 cún chǔ zhí
    sensor types 传感器类型 chuán gǎn qì lèi xíng
    accelerometer 加速度计 jiā sù dù jì
    humidity 湿度 shī dù
    proximity 接近 jiē jìn
    consistent 一致的 yí zhì de
    central heating 中央供暖 zhōng yāng gōng nuǎn
    chemical process 化学过程 huà xué guò chéng
    agriculture 农业 nóng yè
    6.2

    机器人技术

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand what is meant by robotics • Robotics is a branch of computer science that incorporates the design, construction and operation of robots • Examples include factory equipment, domestic robots and drones
    2 Describe the characteristics of a robot • Including: – a mechanical structure or framework – electrical components, such as sensors, microprocessors and actuators – programmable
    3 Understand the roles that robots can perform and describe the advantages and disadvantages of their use • Robots can be used in areas including: – industry – transport – agriculture – medicine – domestic settings – entertainment

    来源:剑桥国际大纲

    机器人技术(robotics)是处理机器人(robots)的设计、建造和操作的技术分支。

    一个机器人有这些特征:

    • 一个物理结构(physical structure,一个机械的(mechanical)身体,如手臂);
    • 电子元件(electrical components,马达、传感器和线路);
    • 可编程指令(programmable instructions)——它遵循一个能被改变的程序。

    What robots do

    机器人能执行许多作用,例如:

    • 工厂设备(factory equipment)——建造汽车、焊接、移动重的部件;
    • 家用电器(domestic appliances)——如一个机器人吸尘器(vacuum cleaner)。
    一条工厂生产线上一个白色机器人臂,周围有电缆和金属框架
    一个工业机器人臂。它遵循一个程序,能被重新编程以做一个新工作。
    从上面看到的一个圆形、扁平的灰色机器人吸尘器,顶上有 S、M 和 L 按钮
    一个机器人吸尘器:一个自己四处驾驶以清洁地板的家庭机器人
    优点 缺点
    做无聊或危险的工作 购买和维护昂贵
    快速而准确地工作 能替换人类工人
    不疲倦或无聊 一个机器人有缺乏独立决策(lack of independent decision-making)——它只做它被编程去做的

    一个机器人的一个关键限制是它不能自己思考。当某样意外的事发生时它不能做它自己的选择。

    探索

    Computing concept lab

    Classify concrete examples by the computing idea they demonstrate.

    词汇表 训练
    英文 中文 拼音
    Robotics 机器人技术 jī qì rén jì shù
    robots 机器人 jī qì rén
    physical structure 物理结构 wù lǐ jié gòu
    electrical components 电子元件 diàn zi yuán jiàn
    programmable instructions 可编程指令 kě biān chéng zhǐ lìng
    factory equipment 工厂设备 gōng chǎng shè bèi
    domestic appliances 家用电器 jiā yòng diàn qì
    vacuum cleaner 吸尘器 xī chén qì
    lack of independent decision-making 缺乏独立决策 quē fá dú lì jué cè
    mechanical 机械的 jī xiè de
    6.3

    人工智能

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand what is meant by artificial intelligence (AI) • AI is a branch of computer science dealing with the simulation of intelligent behaviours by computers
    2 Describe the main characteristics of AI as the collection of data and the rules for using that data, the ability to reason, and it can include the ability to learn and adapt
    3 Explain the basic operation and components of AI systems to simulate intelligent behaviour • Limited to: – expert systems – machine learning • Expert systems have a knowledge base, a rule base, an inference engine and an interface • Machine learning is when a program has the ability to automatically adapt its own processes and/or data

    来源:剑桥国际大纲

    人工智能(artificial intelligence,AI)是计算机系统对人类智能的模拟(simulation)。这意味着一台计算机做通常需要人类思考的任务。

    Characteristics of AI

    AI 系统通常有这些特征:

    • 它们收集数据以及使用那个数据的规则(rules);
    • 它们有推理(reason,用规则算出东西)的能力;
    • 它们有得出结论(draw conclusions)的能力,结论可能是近似的(approximate,一个最佳猜测)或确定的(definite,确定);
    • 它们有从数据学习(learn)的能力;
    • 它们有适应(adapt)的能力——随着它们得到新数据改变它们的行为。
    一个 AI 系统作为一个循环:它收集数据、应用规则并发现模式、按一个决定行动,然后在收集更多数据之前从结果学习并改进
    一个 AI 系统收集数据、应用规则、行动,然后学习并改进

    Examples of AI

    • 专家系统(expert systems)——像一个人类专家一样给出建议的软件(例如,帮助一个医生做一个诊断);
    • 自然语言处理(natural language processing)——理解人类的语音或文本;
    • 自动驾驶汽车(self-driving cars)。
    一条路上一辆小的白色自动驾驶汽车,车顶上一个旋转的传感器
    一辆自动驾驶汽车:车上的传感器让一台计算机在没有司机的情况下驾驶它

    Inside an expert system

    一个专家系统存储人类专长并从中推理。它有四个部分:

    • 一个知识库(knowledge base)——关于该主题的存储事实;
    • 一个规则库(rule base)——一个人类专家会应用的"如果……那么……"规则;
    • 一个推理引擎(inference engine)——把规则应用到事实上以得出一个结论;
    • 一个用户界面(user interface)——向用户提问并显示结果。

    界面从用户收集事实;推理引擎把规则库对知识库运行;而系统输出一个诊断或一个概率——就像用来帮助一名医生诊断疾病或找出一个汽车故障。

    Machine learning

    机器学习(machine learning)是一个从经验改进自己表现、无需被显式重新编程的程序。它在数据里找模式并适应:一个搜索引擎在排名结果上变得更好、一个语音助手更准确地识别口语命令,而一个扫地机器人逐渐学会一个房间的布局。

    Narrow, general and strong AI

    三个上升的台阶:弱人工智能(今天所有的 AI)、通用人工智能和强人工智能,通用和强 AI 被标为还不存在
    弱 AI 做一个任务(今天所有的 AI);通用 AI 能做任何人类任务;强 AI 会有自我意识——两者都还不存在
    类型 它意味着什么
    弱人工智能(narrow AI) 只能做一个任务或一小组任务(例如,一个象棋程序)。今天所有的 AI 都是弱人工智能。
    通用人工智能(general AI) 能做一个人类能做的任何任务,在许多不同的任务之间切换。
    强人工智能(strong AI) 会像一个真实的人类心智一样思考并有意识。这还不存在。
    探索

    Computing concept lab

    Classify concrete examples by the computing idea they demonstrate.

    词汇表 训练
    英文 中文 拼音
    Artificial intelligence 人工智能 rén gōng zhì néng
    simulation 模拟 mó nǐ
    rules 规则 guī zé
    reason 推理 tuī lǐ
    draw conclusions 得出结论 dé chū jié lùn
    approximate 近似的 jìn sì de
    definite 确定的 què dìng de
    learn 学习 xué xí
    adapt 适应 shì yìng
    expert systems 专家系统 zhuān jiā xì tǒng
    natural language processing 自然语言处理 zì rán yǔ yán chǔ lǐ
    self-driving cars 自动驾驶汽车 zì dòng jià shǐ qì chē
    knowledge base 知识库 zhī shí kù
    rule base 规则库 guī zé kù
    inference engine 推理引擎 tuī lǐ yǐn qíng
    user interface 用户界面 yòng hù jiè miàn
    Machine learning 机器学习 jī qì xué xí
    narrow AI 弱人工智能 ruò rén gōng zhì néng
    general AI 通用人工智能 tōng yòng rén gōng zhì néng
    strong AI 强人工智能 qiǎng rén gōng zhì néng
    6.3

    考试技巧

    • 学习控制循环:一个传感器测量一个量 → 微处理器把它与一个存储值比较 → 一个执行器采取行动;然后循环重复。
    • 不要混淆各部分:一个传感器把数据发送;一个执行器引起的运动。
    • 一个机器人遵循可编程指令,而当某样意外的事发生时它不能做它自己的决定。
    • AI 模拟人类思考:它收集数据和规则、推理、得出结论,并能学习和适应。
    • 知道 AI 级别:(一个任务;今天所有的 AI)、通用(任何人类任务)、(有自我意识;还不存在)。
  • 7

    算法设计与问题求解

    讲义 词汇表
    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the program development life cycle, limited to: analysis, design, coding and testing • Including identifying each stage and performing these tasks for each stage: – analysis: abstraction, decomposition of the problem, identification of the problem and requirements – design: decomposition, structure diagrams, flowcharts, pseudocode – coding: writing program code and iterative testing – testing: testing program code with the use of test data
    2 (a) Understand that every computer system is made up of sub-systems, which are made up of further sub-systems (b) Understand how a problem can be decomposed into its component parts • Including: – inputs – processes – outputs – storage
    (c) Use different methods to design and construct a solution to a problem • Including: – structure diagrams – flowcharts – pseudocode
    3 Explain the purpose of a given algorithm • Including: – stating the purpose of an algorithm – describing the processes involved in an algorithm
    4 Understand standard methods of solution • Limited to: – linear search – bubble sort – totalling – counting – finding maximum, minimum and average values
    5 (a) Understand the need for validation checks to be made on input data and the different types of validation check • Including: – range check – length check – type check – presence check – format check – check digit
    (b) Understand the need for verification checks to be made on input data and the different types of verification check • Including: – visual check – double entry check
    6 Suggest and apply suitable test data • Limited to: – normal – abnormal – extreme – boundary • Extreme data is the largest/smallest acceptable value • Boundary data is the largest/smallest acceptable value and the corresponding smallest/largest rejected value
    7 Complete a trace table to document a dry-run of an algorithm • Including, at each step in an algorithm: – variables – outputs – user prompts
    8 Identify errors in given algorithms and suggest ways of correcting these errors
    9 Write and amend algorithms for given problems or scenarios, using: pseudocode, program code and flowcharts • Precision is required when writing algorithms, e.g. x > y is acceptable but x is greater than y is not acceptable • See section 4 for flowchart symbols • See section 4 for pseudocode

    来源:剑桥国际大纲

    7.1

    程序开发生命周期

    程序开发生命周期(program development life cycle)是用来制作一个程序的一套阶段。有四个阶段。

    一个程序员在一台计算机前键入代码
    软件由程序员编写,他们遵循开发生命周期
    阶段 你做什么
    分析(analysis) 研究问题并算出需要什么
    设计(design) 规划程序将如何工作
    编码(coding) 编写程序代码并随手测试它
    测试(testing) 用测试数据运行完成的程序以找到错误
    一排四个阶段——分析、设计、编码、测试——一个箭头从测试反馈到设计
    程序开发的四个阶段;测试反馈以修复和精炼设计
    一个带处理框和判断菱形的程序流程图
    一个程序流程图在设计阶段布置一个程序的步骤和判断

    Analysis

    在分析中你理解问题。两个关键技能有帮助:

    • 抽象(abstraction)——只保留重要的细节并忽略其余的;
    • 分解(decomposition)——把一个大问题分成更小、更容易的部分。

    Design

    在设计中你规划解决方案,常常用分解。你可以把各部分显示为一个结构图(structure diagram,一个把一个系统分成更小的框的图)中的子系统(sub-systems)。

    Coding and testing

    编码中你编写程序代码。你用迭代测试(iterative testing)——在你构建小部分时一遍又一遍地测试它们。在测试中你用测试数据(test data)运行整个程序以检查它工作。

    词汇表 训练
    英文 中文 拼音
    program development life cycle 程序开发生命周期 chéng xù kāi fā shēng mìng zhōu qī
    analysis 分析 fēn xī
    design 设计 shè jì
    coding 编码 biān mǎ
    testing 测试 cè shì
    abstraction 抽象 chōu xiàng
    decomposition 分解 fēn jiě
    sub-systems 子系统 zi xì tǒng
    structure diagram 结构图 jié gòu tú
    iterative testing 迭代测试 dié dài cè shì
    test data 测试数据 cè shì shù jù
    flowchart 流程图 liú chéng tú
    7.2

    设计工具

    你可以用三种主要方式规划一个解决方案。

    • 一个结构图(structure diagram)——显示一个系统的各部分以及它们如何组合在一起;
    • 一个流程图(flowchart)——一个用框和箭头按顺序显示步骤的图;
    • 伪代码(pseudocode)——用简单的、类似代码的英语书写的步骤(不是一门真实的语言)。
    一个把数字 1 加到 n 的流程图,带开始/结束、输入/输出、处理和判断符号,加上一个命名每个形状的图例
    求和算法的一个流程图,用标准符号(开始/结束、输入/输出、处理、判断)
    词汇表 训练
    英文 中文 拼音
    pseudocode 伪代码 wěi dài mǎ
    7.3

    算法

    冒泡排序,一趟接一趟

    一个算法(algorithm)是解决一个问题的一套步骤,以正确的顺序。每个算法能被分成三部分:

    • 输入(input)——进去的数据;
    • 处理(processing)——对数据做的工作;
    • 输出(output)——出来的结果。

    这叫分解成输入、处理和输出。例如,对于"求三个分数的平均值":输入是三个分数;处理是把它们相加并除以 3;输出是平均值。

    三个框——INPUT(3 个分数)、PROCESS(把它们相加,除以 3)、OUTPUT(平均值)——由箭头连接
    每个算法分解成输入、处理和输出——这里,求三个分数的平均值
    词汇表 训练
    英文 中文 拼音
    algorithm 算法 suàn fǎ
    input 输入 shū rù
    processing 处理 chǔ lǐ
    output 输出 shū chū
    7.4

    有效性检查与准确性检查

    当数据被输入时,你检查它以减少错误。

    验证(validation)检查数据是合理的并遵循规则。它不能检查数据是真的,只能检查它是被允许的。

    验证检查 它检查什么
    范围检查(range check) 值在一个最低和最高允许值之间
    长度检查(length check) 字符的数目被允许(例如一个密码 ≥ 8)
    类型检查(type check) 数据是正确的类型(例如一个数,而不是字母)
    存在性检查(presence check) 某样东西实际被输入(没有留空)
    格式检查(format check) 数据在正确的模式中(例如一个日期作为 dd/mm/yyyy)
    校验码(check digit) 一个额外的数字确认一个数被正确地输入

    核实(verification)检查数据被正确地复制或输入(键入它时没有错误)。两种方法:

    • 目视检查(visual check)——一个人把键入的数据与原始比较;
    • 双重输入(double entry)——数据被输入两次,而两个副本被比较。
    词汇表 训练
    英文 中文 拼音
    validation 验证 yàn zhèng
    range check 范围检查 fàn wéi jiǎn chá
    length check 长度检查 cháng dù jiǎn chá
    type check 类型检查 lèi xíng jiǎn chá
    presence check 存在性检查 cún zài xìng jiǎn chá
    format check 格式检查 gé shì jiǎn chá
    check digit 校验码 jiào yàn mǎ
    verification 核实 hé shí
    visual check 目视检查 mù shì jiǎn chá
    double entry 双重输入 shuāng chóng shū rù
    7.5

    跟踪表

    一个追踪表(trace table)一步步地记录一个算法运行时每个变量的值。它帮助你:

    一个追踪表,带列 count、total、output
    一个追踪表在程序运行时记录每个变量的值
    • 检查一个算法正确地工作;
    • 通过用给定的数据跟随它来算出一个算法做什么

    例子:用输入 5 追踪这个算法。

    INPUT n
    total ← 0
    FOR i ← 1 TO n
        total ← total + i
    NEXT i
    OUTPUT total
    
    i total OUTPUT
    1 1
    2 3
    3 6
    4 10
    5 15 15

    追踪显示算法把 1 到 n 相加。用输入 5,输出是 15。

    例题。 追踪这个算法并给出输出。

    x ← 20
    count ← 0
    WHILE x > 1
        x ← x DIV 2
        count ← count + 1
    ENDWHILE
    OUTPUT count
    

    DIV 只取除法的整数部分。每循环一次写一行:x 变成 10(count 为 1),然后 5(count 为 2),然后 2(count 为 3),然后 1(count 为 4)。此时 x > 1 为假,所以循环结束,输出是 4。有两个习惯能保住这些分:在每次循环之前而不是之后检验条件;以及每一次循环都新写一行 - 想把这些值记在脑子里,正是追踪出错的原因。

    探索

    A trace table

    Step through the loop and fill in the trace table, one row per pass.

    词汇表 训练
    英文 中文 拼音
    trace table 追踪表 zhuī zōng biǎo
    7.6

    测试数据

    测试数据(test data)是你用来测试一个程序的数据。有四种你必须知道的类型。

    类型 意义 例子(年龄 0–120 允许)
    正常数据(normal) 应当被接受的合理数据 25
    异常数据(abnormal) 应当被拒绝的错误数据 -4 或 "cat"
    极端数据(extreme) 仍被允许的最大和最小值 0 和 120
    边界数据(boundary) 一个限制每一侧的值(一个允许,一个不) 120 和 121
    词汇表 训练
    英文 中文 拼音
    normal 正常数据 zhèng cháng shù jù
    abnormal 异常数据 yì cháng shù jù
    extreme 极端数据 jí duān shù jù
    boundary 边界数据 biān jiè shù jù
    7.7

    标准解题方法

    你必须知道这些常见的算法。

    Linear search

    一个线性查找(linear search)逐个检查一个列表中的每个项,直到它找到它想要的值或到达末端。

    found ← FALSE
    FOR i ← 0 TO 9
        IF list[i] = searchValue THEN
            found ← TRUE
        ENDIF
    NEXT i
    OUTPUT found
    
    一个八个数的列表从左到右被扫描,搜索 5;前四个不匹配,而第五个被找到
    线性查找从开始依次检查每个项,直到它找到值

    Bubble sort

    一个冒泡排序(bubble sort)把一个列表排序。它比较每对并排的项,若它们顺序错误就交换它们。它重复这个直到不再需要交换。

    FOR i ← 0 TO 8
        IF list[i] > list[i + 1] THEN
            temp ← list[i]
            list[i] ← list[i + 1]
            list[i + 1] ← temp
        ENDIF
    NEXT i
    
    一个列表,第一对 5 和 2 顺序错误,显示交换成 2 和 5,带一个对每对重复的注释
    冒泡排序比较每对并排的对,若它们顺序错误就交换它们,重复直到排序好

    Totalling and counting

    • 求和(totalling)——不断把值加到一个运行中的总数(total ← total + value)。
    • 计数(counting)——每次某样东西发生时给一个计数器加 1(count ← count + 1)。

    Maximum, minimum and average

    • 要求最大值(maximum):保留到目前为止见过的最大值。
    • 要求最小值(minimum):保留到目前为止见过的最小值。
    • 要求平均值(average):把总数除以有多少个值。
    total ← 0
    FOR i ← 0 TO 9
        total ← total + list[i]
    NEXT i
    average ← total / 10
    OUTPUT average
    
    词汇表 训练
    英文 中文 拼音
    linear search 线性查找 xiàn xìng chá zhǎo
    bubble sort 冒泡排序 mào pào pái xù
    totalling 求和 qiú hé
    counting 计数 jì shù
    maximum 最大值 zuì dà zhí
    minimum 最小值 zuì xiǎo zhí
    average 平均值 píng jūn zhí
    7.8

    考试技巧

    • 学习四个生命周期阶段:分析 → 设计 → 编码 → 测试。抽象只保留重要的细节;分解把一个问题分成更小的部分。
    • 验证检查数据是合理的(范围、长度、类型、存在性、格式检查);核实检查它被正确地复制(一个目视检查或双重输入)。
    • 学习四种测试数据类型:正常(被接受)、异常(被拒绝)、极端(仍被允许的最大/最小)、边界(一个限制两侧的值)。
    • 要算出一个算法做什么,填一个追踪表——写下每个变量在每一步的值。
    • 知道标准算法:线性查找(依次检查每个项)和冒泡排序(交换并排的对直到不需要交换)。
  • 8

    程序设计

    讲义 词汇表
    8.1

    编程概念

    大纲
    Candidates should be able to: Notes and guidance
    1 Declare and use variables and constants
    2 Understand and use basic data types • Including: – integer – real – char – string – Boolean
    3 Understand and use input and output
    4 (a) Understand and use the concept of sequence
    (b) Understand and use the concept of selection • Including: – IF statements – CASE statements
    (c) Understand and use the concept of iteration • Including: – count-controlled loops – pre-condition loops – post-condition loops
    (d) Understand and use the concepts of totalling and counting
    (e) Understand and use the concept of string handling • Including: – length – substring – upper – lower • The first character of the string can be position zero or one
    (f) Understand and use arithmetic, relational and logical operators • Arithmetic, limited to: – + – – – / – * – ^ (raised to power of) – MOD – DIV • Relational, limited to: – = – < – <= – > – >= – <> (not equal to) • Logical, limited to: – AND – OR – NOT
    5 Understand and use nested statements • Including nested selection and iteration • Candidates will not be required to write more than three levels of nested statements
    6 (a) Understand what is meant by procedures, functions and parameters (b) Define and use procedures and functions, with or without parameters (c) Understand and use local and global variables • Procedures and functions may have up to three parameters
    7 Understand and use library routines • Including: – MOD – DIV – ROUND – RANDOM
    8 Understand how to create a maintainable program • Including appropriate use of: – meaningful identifiers – the commenting feature provided by the programming language – procedures and functions – relevant and appropriate commenting of syntax • Use meaningful identifiers for: – variables – constants – arrays – procedures and functions

    来源:剑桥国际大纲

    一个变量(variable)是一个有名字的存储,容纳一个在程序运行时能改变的值。一个常量(constant)是一个有名字的存储,它的值是固定的、不改变。

    一个名为 age 的变量,容纳值 16
    一个变量是一个有名字的存储,它的值能改变
    屏幕上一行行程序代码
    变量和常量是值的有名字的存储,在程序的代码中设定

    你应当在使用前声明(declare)它们(说它们的名称和类型):

    DECLARE score : INTEGER
    DECLARE name : STRING
    CONSTANT Pi = 3.142
    
    两个 RAM 内存模块
    当一个程序运行时,它的变量被容纳在计算机的内存(RAM)中

    对一个从不改变的值(如 Pi)用一个常量,所以它在一处被设定,而且容易阅读。

    探索

    Variables and assignment

    Step through the lines and watch each variable take its new value.

    词汇表 训练
    英文 中文 拼音
    variable 变量 biàn liàng
    constant 常量 cháng liàng
    declare 声明 shēng míng
    integer 整数 zhěng shù
    string 字符串 zì fú chuàn
    8.1

    数据类型

    一个数据类型(data type)说明一个变量容纳什么种类的值。你必须知道五种基本类型。

    数据类型:整数(7)、实数(3.5)、字符('A')、字符串("hello")、布尔值(true/false)
    基本数据类型:整数、实数、字符、字符串和布尔值
    类型 容纳 例子
    整数(integer) 一个整数 42-7
    实数(real) 一个带小数点的数 3.14-0.5
    字符(char) 一个单一字符 'A''?'
    字符串(string) 一个字符序列 "Hello"
    布尔值(Boolean) 两个值之一 TRUEFALSE
    词汇表 训练
    英文 中文 拼音
    data type 数据类型 shù jù lèi xíng
    real 实数 shí shù
    char 字符 zì fú
    Boolean 布尔值 bù ěr zhí
    8.1

    输入与输出

    输入(input)从用户读一个值。输出(output)在屏幕上显示一个值。

    OUTPUT "What is your name?"
    INPUT name
    OUTPUT "Hello ", name
    
    词汇表 训练
    英文 中文 拼音
    input 输入 shū rù
    output 输出 shū chū
    8.1

    三种基本结构

    每个程序从三个控制结构构建。

    三个小流程图:顺序(一行框)、选择(一个测试两路分支)和迭代(一个测试,主体循环回去)
    三个控制结构:顺序按顺序运行步骤、选择选择一个分支、迭代重复一个主体

    Sequence

    顺序(sequence)意味着步骤一个接一个地运行,按顺序,从上到下。

    INPUT length
    INPUT width
    area ← length * width
    OUTPUT area
    

    Selection

    选择(selection)基于一个条件选择哪些步骤运行。用一个 IF 语句,或当有许多选择时用一个 CASE 语句。

    IF score >= 50 THEN
        OUTPUT "Pass"
    ELSE
        OUTPUT "Fail"
    ENDIF
    
    CASE OF grade
        'A' : OUTPUT "Excellent"
        'B' : OUTPUT "Good"
        OTHERWISE : OUTPUT "Keep trying"
    ENDCASE
    

    Iteration

    迭代(iteration,一个循环(loop))重复步骤。有三种。

    一个计数循环(count-controlled loop)重复一个固定的次数:

    FOR i ← 1 TO 5
        OUTPUT "Hello"
    NEXT i
    

    一个前测循环(pre-condition loop)在每次重复之前检查条件,所以它可能运行零次:

    WHILE answer <> "stop" DO
        INPUT answer
    ENDWHILE
    

    一个后测循环(post-condition loop)在每次重复之后检查条件,所以它总是运行至少一次:

    REPEAT
        INPUT password
    UNTIL password = "secret"
    
    两个循环流程图:WHILE 在主体之前测试条件;REPEAT 先运行主体、之后测试
    一个前测(WHILE)循环在主体之前测试,所以它可能运行零次;一个后测(REPEAT)循环之后测试,所以它至少运行一次
    探索

    How an IF … ELSE IF ladder decides

    The conditions are tested top to bottom; the FIRST one that is true runs and the rest are skipped. Slide the score and watch which branch lights up.

    探索

    Selection

    Change the value and watch which branch runs — selection in action.

    词汇表 训练
    英文 中文 拼音
    sequence 顺序 shùn xù
    selection 选择 xuǎn zé
    iteration 迭代 dié dài
    loop 循环 xún huán
    count-controlled loop 计数循环 jì shù xún huán
    pre-condition loop 前测循环 qián cè xún huán
    post-condition loop 后测循环 hòu cè xún huán
    length 长度 cháng dù
    8.1

    求和与计数

    • 求和(totalling)——不断把值加到一个运行中的总数:total ← total + value
    • 计数(counting)——每次给一个计数器加 1:count ← count + 1
    count = count + 1 按 1 计数;total = total + value 加到一个运行中的总数
    一个计数器按 1 计数;一个总数构建一个运行中的和
    一个追踪表,跟随一个在值 4、7 和 5 上的循环:total 走 0、4、11、16,而 count 走 0、1、2、3
    一个追踪表一趟接一趟地跟随一个求和和计数的循环
    total ← 0
    FOR i ← 1 TO 10
        INPUT mark
        total ← total + mark
    NEXT i
    OUTPUT total
    

    例题。 一个程序要读入 5 个分数,然后输出总分和平均分。

    total ← 0
    FOR i ← 1 TO 5
        INPUT mark
        total ← total + mark
    NEXT i
    average ← total / 5
    OUTPUT total, average
    

    有两行是得分点。total ← 0 必须放在循环之前:放进循环里,总和每次都会被清零,程序最后只会输出最后一个分数。而 average ← total / 5 必须放在循环之后,因为在所有分数都加完之前,总和还不完整。先初始化,后计算 - 这个先后顺序才是题目真正考的东西。

    词汇表 训练
    英文 中文 拼音
    totalling 求和 qiú hé
    counting 计数 jì shù
    8.1

    运算符

    Arithmetic operators

    运算符 意义
    + - * / 加、减、乘、除
    ^ 提升到……次幂
    MOD 除法后的余数(remainder)
    DIV 一个除法的整数部分

    例如,17 MOD 52,而 17 DIV 53

    Relational operators

    这些比较两个值并给出一个布尔结果:=<<=>>=,以及 <>(不等于)。

    Logical operators

    这些连接条件:AND(两者都必须为真)、OR(至少一个必须为真)、NOT(反转真/假)。

    三族运算符:像加和乘的算术运算符给一个数、像小于的关系运算符比较并给真或假、逻辑运算符 AND OR NOT 连接条件
    三族运算符:算术、关系和逻辑
    IF age >= 13 AND age <= 19 THEN
        OUTPUT "Teenager"
    ENDIF
    
    词汇表 训练
    英文 中文 拼音
    remainder 余数 yú shù
    8.1

    字符串处理

    一个字符串由字符构成。有用的操作:

    • 长度(length)——字符串中字符的数目;
    • 子串(substring)——从字符串取出的一个更小的部分;
    • 大写(upper case)——把字母改成大写;
    • 小写(lower case)——把字母改成小写。
    name ← "Computer"
    OUTPUT LENGTH(name)          // 8
    OUTPUT SUBSTRING(name, 1, 4) // "Comp"
    OUTPUT UCASE(name)           // "COMPUTER"
    OUTPUT LCASE(name)           // "computer"
    

    (第一个字符可能被数为位置 0 或位置 1,取决于语言。)

    探索

    Index and slice a string

    Every character has a position (index). A slice takes the characters from the start index up to — but not including — the end index, just like SUBSTRING does.

    词汇表 训练
    英文 中文 拼音
    substring 子串 zi chuàn
    upper case 大写 dà xiě
    lower case 小写 xiǎo xiě
    8.1

    嵌套语句

    一个嵌套语句(nested statement)是放在另一个里面的一个控制结构。你可以嵌套选择和迭代。

    FOR i ← 1 TO 3
        IF i MOD 2 = 0 THEN
            OUTPUT i, " is even"
        ELSE
            OUTPUT i, " is odd"
        ENDIF
    NEXT i
    

    你不会必须写多于三层的嵌套。

    词汇表 训练
    英文 中文 拼音
    nested statement 嵌套语句 qiàn tào yǔ jù
    8.1

    过程与函数

    为了避免重复代码,你可以把一个程序分成有名字的块。

    • 一个过程(procedure)是做一个任务的一个有名字的代码块。你用 CALL 运行它。
    • 一个函数(function)像一个过程,但它把一个值返回到它被调用的地方。

    一个参数(parameter)是一个传入一个过程或函数的值(最多三个参数)。

    PROCEDURE Greet(personName : STRING)
        OUTPUT "Hello ", personName
    ENDPROCEDURE
    
    CALL Greet("Sam")
    
    FUNCTION Square(n : INTEGER) RETURNS INTEGER
        RETURN n * n
    ENDFUNCTION
    
    answer ← Square(5)   // answer is 25
    

    Local and global variables

    • 一个局部变量(local variable)在一个过程或函数里面声明。它只能在那里被使用。
    • 一个全局变量(global variable)在主程序中声明。它能在任何地方被使用。

    局部变量更安全,因为它们不能被程序另一部分错误地改变。

    词汇表 训练
    英文 中文 拼音
    procedure 过程 guò chéng
    function 函数 hán shù
    parameter 参数 cān shù
    local variable 局部变量 jú bù biàn liàng
    global variable 全局变量 quán jú biàn liàng
    8.1

    库函数

    一个库程序(library routine)是你能使用的一段现成的代码。你必须知道这些:

    程序 它做什么
    MOD 给一个除法的余数
    DIV 给一个除法的整数部分
    ROUND 把一个实数舍入到若干小数位
    RANDOM 给一个随机数
    词汇表 训练
    英文 中文 拼音
    library routine 库程序 kù chéng xù
    8.1

    编写易于维护的程序

    一个可维护的(maintainable)程序对其他人来说以后容易阅读和改变。要制作一个:

    • 有意义的标识符(meaningful identifiers)——变量、常量、数组、过程和函数的清晰名称(totalScore,不是 x);
    • 注释(comments)以解释代码的各部分做什么;
    • 用过程和函数把工作分成小块。
    词汇表 训练
    英文 中文 拼音
    maintainable 可维护的 kě wéi hù de
    meaningful identifiers 有意义的标识符 yǒu yì yì de biāo shí fú
    comments 注释 zhù shì
    8.2

    数组

    大纲
    Candidates should be able to: Notes and guidance
    1 Declare and use one-dimensional (1D) and two-dimensional (2D) arrays
    2 Understand the use of arrays • Including the use of variables as indexes in arrays
    3 Write values into, and read values from, an array using iteration • The first index can be zero or one • Including nested iteration

    来源:剑桥国际大纲

    一个数组(array)是一个单一变量,容纳同一类型的许多值,由一个索引(index,一个位置号)找到。

    One-dimensional arrays

    一个一维(1D)数组(one-dimensional array)像一个单一的列表。

    DECLARE scores : ARRAY[1:5] OF INTEGER
    scores[1] ← 90
    scores[2] ← 75
    OUTPUT scores[1]
    
    一行五个框,标注索引 1 到 5,容纳值,索引 2 处的值被高亮为 75
    一个 1D 数组在一个变量中容纳许多值;每个由它的索引找到

    你可以用一个循环填充或读取一个数组:

    FOR i ← 1 TO 5
        INPUT scores[i]
    NEXT i
    

    Two-dimensional arrays

    一个二维(2D)数组(two-dimensional array)像一个带行和列的表。它用两个索引。

    DECLARE grid : ARRAY[1:3, 1:3] OF INTEGER
    grid[1, 1] ← 5
    grid[2, 3] ← 8
    
    一个 3 乘 3 的网格,带编号的行和列;第 2 行第 3 列的单元被高亮并标注为 grid 第 2 行第 3 列
    一个 2D 数组是一个表;每个值由两个索引 [行, 列] 找到

    你用一个循环里面的一个循环(嵌套迭代)读一个 2D 数组。

    探索

    Arrays

    Pick a position to read one element — how a list (array) is indexed.

    词汇表 训练
    英文 中文 拼音
    array 数组 shù zǔ
    index 索引 suǒ yǐn
    one-dimensional (1D) array 一维数组 yī wéi shù zǔ
    two-dimensional (2D) array 二维数组 èr wéi shù zǔ
    8.3

    文件处理

    大纲
    Candidates should be able to: Notes and guidance
    1 Understand the purpose of storing data in a file to be used by a program
    2 Open, close and use a file for reading and writing • Including: – read and write single items of data – read and write a line of text

    来源:剑桥国际大纲

    一个程序可以把数据存储在一个文件(file)中,所以它在程序停止后被保留。你必须打开文件、使用它,然后关闭它。

    OPENFILE "data.txt" FOR WRITE
    WRITEFILE "data.txt", "Hello"
    CLOSEFILE "data.txt"
    
    OPENFILE "data.txt" FOR READ
    READFILE "data.txt", line
    CLOSEFILE "data.txt"
    

    你可以读和写单个数据项或一整行文本。当你完成使用一个文件时总是关闭它。

    词汇表 训练
    英文 中文 拼音
    file 文件 wén jiàn
    8.3

    考试技巧

    • 一个变量能在程序运行时改变;一个常量是固定的。学习五种数据类型:整数、实数、字符、字符串、布尔值。
    • 每个程序从三个结构构建:顺序选择(IF / CASE),和迭代(循环)。
    • 一个 WHILE 循环在主体之前测试,所以它可能运行零次;一个 REPEAT … UNTIL 循环之后测试,所以它总是至少运行一次。
    • MOD 给余数,而 DIV 给一个除法的整数部分:17 MOD 5 是 2,17 DIV 5 是 3。
    • 一个函数返回一个值;一个过程不返回。一个局部变量只在它的块里面工作;一个全局的在任何地方工作。
  • 9

    数据库

    讲义 词汇表
    大纲
    Candidates should be able to: Notes and guidance
    1 Define a single-table database from given data storage requirements • Including: – fields – records – validation
    2 Suggest suitable basic data types • Including: – text/alphanumeric – character – Boolean – integer – real – date/time
    3 Understand the purpose of a primary key and identify a suitable primary key for a given database table
    4 Read, understand and complete structured query language (SQL) scripts to query data stored in a single database table • Limited to: – SELECT – FROM – WHERE – ORDER BY DESCENDING – ORDER BY ASCENDING – SUM – COUNT – AND – OR • Identifying the output given by an SQL statement that will query the given contents of a database table

    来源:剑桥国际大纲

    9.1

    什么是数据库?

    一个数据库(database)是一个有组织的数据存储,被保存得容易搜索、排序和更新。在 IGCSE 你用一个单表数据库(single-table database)——所有的数据都容纳在一个表中。

    一个图书馆卡片目录里一排排小的标注的抽屉
    一个图书馆卡片目录是纸上的一个数据库——你能按索引搜索和排序的记录
    一个数据中心里一排排服务器
    大型现代数据库存储在数据中心的服务器上
    词汇表 训练
    英文 中文 拼音
    database 数据库 shù jù kù
    single-table database 单表数据库 dān biǎo shù jù kù
    9.2

    记录与字段

    一个数据库表由记录和字段构成。

    • 一个记录(record)是表中的一行——关于一件事物的所有数据(例如一个学生)。
    • 一个字段(field)是表中的一列——每个记录都有的一份数据(例如"名字")。
    StudentID FirstName DateOfBirth FormClass FeesPaid
    1 Amy 14/03/2009 10A TRUE
    2 Ben 02/11/2008 10B FALSE

    这里每一是一个记录,而每一是一个字段。

    Student 表,每一行被标为一个记录、每一列为一个字段,而 StudentID 列被高亮为主键
    每一行是一个记录,而每一列是一个字段;主键(StudentID)对每个记录唯一
    词汇表 训练
    英文 中文 拼音
    record 记录 jì lù
    field 字段 zì duàn
    9.3

    字段的数据类型

    每个字段存储一个数据类型(data type)。你选择最适合数据的类型。

    字段类型:文本(一个名字)、数字(一个年龄)、日期/时间(一个生日)、布尔值(是/否)
    字段类型:文本、数字、日期/时间和布尔值
    数据类型 用于 例子
    文本/字母数字(text/alphanumeric) 字母、数字和符号 "10A"、"Amy"
    字符(character) 一个单一字符 'M'
    布尔值(Boolean) 两个值之一 TRUE / FALSE
    整数(integer) 一个整数 42
    实数(real) 一个带小数点的数 3.5
    日期时间(date/time) 一个日期或一个时间 14/03/2009
    词汇表 训练
    英文 中文 拼音
    data type 数据类型 shù jù lèi xíng
    text/alphanumeric 文本 wén běn
    character 字符 zì fú
    Boolean 布尔值 bù ěr zhí
    integer 整数 zhěng shù
    real 实数 shí shù
    date/time 日期时间 rì qī shí jiān
    9.4

    主键

    一个主键(primary key)是一个为每个记录容纳一个唯一的(unique)值的字段。没有两个记录能有同样的主键,所以它让你精确地挑出一个记录。

    在上面的表中,StudentID 是一个好的主键,因为每个学生有一个不同的数。一个像 FormClass 的字段会是一个糟糕的主键,因为许多学生共享同一个班。

    词汇表 训练
    英文 中文 拼音
    primary key 主键 zhǔ jiàn
    unique 唯一的 wéi yī de
    9.5

    数据库中的有效性检查

    当数据被放入一个数据库时,验证(validation)检查确保它是合理的——例如对一个年龄字段的一个范围检查,或一个存在性检查使一个字段不被留空。(你在主题 7 中看到过这些检查。)

    对一个年龄字段的一个范围检查接受 16 但拒绝 200
    一个范围检查接受合理的值并拒绝其余的
    词汇表 训练
    英文 中文 拼音
    validation 验证 yàn zhèng
    9.6

    结构化查询语言(SQL)

    结构化查询语言(Structured Query Language,SQL)是一种用来查询(query)一个数据库——挑出你想要的记录——的语言。你必须理解并完成 SQL 脚本。

    SELECT, FROM and WHERE

    • SELECT 说明显示哪些字段
    • FROM 说明用哪个表
    • WHERE 给一个条件(condition),所以只显示匹配的记录。
    一个 SQL 查询:SELECT name FROM students WHERE age > 15
    SELECT 挑选字段,FROM 命名表,WHERE 设定条件
    SELECT FirstName, FormClass
    FROM Student
    WHERE FeesPaid = TRUE;
    

    这显示每个已付费的学生的名字和班级。

    * 选择所有字段:

    SELECT *
    FROM Student
    WHERE FormClass = '10A';
    

    ORDER BY

    ORDER BY 排序结果。用 ASC 表示升序(ascending,最小的先,A→Z)或用 DESC 表示降序(descending,最大的先,Z→A)。

    SELECT FirstName, DateOfBirth
    FROM Student
    ORDER BY DateOfBirth ASC;
    

    AND and OR

    AND(两者都必须为真)或 OR(至少一个必须为真)连接条件。

    SELECT FirstName
    FROM Student
    WHERE FormClass = '10A' AND FeesPaid = FALSE;
    

    SUM and COUNT

    • SUM 把一个数字字段中的值加起来。
    • COUNT 数有多少记录匹配。
    SELECT COUNT(StudentID)
    FROM Student
    WHERE FeesPaid = FALSE;
    

    这数有多少学生还没付费。SUM 以同样的方式工作,但加一个数字字段而不是数行。

    Working out the output

    要找到一个 SQL 脚本的输出,按这个顺序读它:

    1. FROM——哪个表;
    2. WHERE——只保留匹配条件的记录;
    3. SELECT——只显示选定的字段;
    4. ORDER BY——把结果排序。
    四个步骤按顺序:FROM(哪个表)、WHERE(保留匹配的行)、SELECT(显示选定的字段)、ORDER BY(排序结果)
    按这个顺序读一个 SQL 查询:FROM(哪个表)、WHERE(哪些行)、SELECT(哪些字段)、ORDER BY(排序)

    遵循这些步骤,你可以精确地写下查询返回哪些行和列。

    例题。 一个 Book 表有字段 TitleAuthorPriceInStock。写一个查询,显示 Orwell 所著且有库存的每本书的书名和价格,最便宜的排在前面。

    SELECT Title, Price
    FROM Book
    WHERE Author = 'Orwell' AND InStock = TRUE
    ORDER BY Price ASC;
    

    按阅读顺序来构建:FROM 指出是哪个表;WHERE 只保留匹配的记录,因为有两个条件,所以要用 AND;SELECT 只显示题目要求的那两个字段;ORDER BY … ASC 把它们排序。文本值要加引号,而且只有题目要求的字段才应出现在 SELECT 中 - 仅仅因为你按 Author 筛选过就把它也加进去,是这里最常见的丢分方式。

    探索

    SELECT … WHERE

    Step through a query: WHERE filters rows, SELECT picks columns.

    词汇表 训练
    英文 中文 拼音
    structured query language 结构化查询语言 jié gòu huà chá xún yǔ yán
    query 查询 chá xún
    condition 条件 tiáo jiàn
    ascending 升序 shēng xù
    descending 降序 jiàng xù
    9.7

    考试技巧

    • 一个记录是一行(关于一件事物的所有数据);一个字段是一列(每个记录都有的一项)。
    • 一个主键对每个记录必须唯一,所以它精确地挑出一个记录(StudentID,而不是 FormClass)。
    • 学习 SQL 各部分:SELECT(哪些字段)、FROM(哪个表)、WHERE(条件)、ORDER BY(排序,ASC 或 DESC)。
    • FROM → WHERE → SELECT → ORDER BY 的顺序读一个查询以算出它的输出。
    • COUNT 数匹配的记录;SUM 加起来一个数字字段。
  • 10

    布尔逻辑

    讲义 词汇表
    大纲
    Candidates should be able to: Notes and guidance
    1 Identify and use the standard symbols for logic gates • See section 4 for logic gate symbols
    2 Define and understand the functions of logic gates • Including: – NOT – AND – OR – NAND – NOR – XOR (EOR) – the binary output produced from all the possible binary inputs • NOT is a single input gate • All other gates are limited to two inputs
    3 (a) Use logic gates to create given logic circuits from a: (i) problem statement (ii) logic expression (iii) truth table (b) Complete a truth table from a: (i) problem statement (ii) logic expression (iii) logic circuit • Circuits must be drawn for the statement given, without simplification • Logic circuits will be limited to a maximum of three inputs and one output • An example truth table with three inputs, for completion: A B C Output | 0 0 0 | 0 0 1 | 0 1 0 | 0 1 1 | 1 0 0 | 1 0 1 | 1 1 0 | 1 1 1
    (c) Write a logic expression from a: (i) problem statement (ii) logic circuit (iii) truth table

    来源:剑桥国际大纲

    10.1

    什么是布尔逻辑?

    布尔逻辑(Boolean logic)用的值工作。在电子学中这些被显示为 1(真)和 0(假)。一个逻辑门(logic gate)取一个或多个这些输入并给一个输出,遵循一个固定的规则。

    一个真值表(truth table)列出每一个可能的输入集及每个的输出。你通过写出所有的输入组合来构建它。

    一个建在面包板上的电子电路
    逻辑门从像这样的电子电路构建,每个门在 1 和 0 上开关
    词汇表 训练
    英文 中文 拼音
    Boolean logic 布尔逻辑 bù ěr luó jí
    logic gate 逻辑门 luó jí mén
    truth table 真值表 zhēn zhí biǎo
    10.2

    六种逻辑门

    行动中的一个逻辑电路:半加器

    你必须知道六个门。NOT 有一个输入;其他所有的有两个输入(A 和 B)。

    六个逻辑门符号——NOT、AND、OR、NAND、NOR 和 XOR——每个带标注的输入和一个输出
    六个逻辑门。输出上的一个小圆圈意味着结果被反转(NOT、NAND、NOR)
    三个小的黑色计算机芯片,带一排排金属针脚,每个印着一个代码
    一个真实的逻辑芯片:里面是像这一页上的逻辑门

    NOT gate

    非门(NOT gate)反转输入。当输入是 0 时输出是 1。

    A Output
    0 1
    1 0

    AND gate

    与门(AND gate)只在两个输入都是 1 时给输出 1。

    AND 的真值表:只有 1 AND 1 给 1
    AND 只在两个输入都是 1 时输出 1
    A B Output
    0 0 0
    0 1 0
    1 0 0
    1 1 1

    OR gate

    或门(OR gate)在至少一个输入是 1 时给输出 1。

    OR 的真值表:0 OR 0 给 0,其余给 1
    OR 在任一输入是 1 时输出 1
    A B Output
    0 0 0
    0 1 1
    1 0 1
    1 1 1

    NAND gate

    与非门(NAND gate)是 AND 后跟 NOT。输出是 AND 的相反

    A B Output
    0 0 1
    0 1 1
    1 0 1
    1 1 0

    NOR gate

    或非门(NOR gate)是 OR 后跟 NOT。输出是 OR 的相反

    A B Output
    0 0 1
    0 1 0
    1 0 0
    1 1 0

    XOR gate

    异或门(XOR gate,异或)在输入不同时给输出 1。

    A B Output
    0 0 0
    0 1 1
    1 0 1
    1 1 0
    探索

    The logic gates

    Switch the inputs and pick a gate to see its output — AND, OR, NOT, NAND, NOR, XOR.

    词汇表 训练
    英文 中文 拼音
    NOT gate 非门 fēi mén
    AND gate 与门 yǔ mén
    OR gate 或门 huò mén
    NAND gate 与非门 yǔ fēi mén
    NOR gate 或非门 huò fēi mén
    XOR gate 异或门 yì huò mén
    10.3

    逻辑表达式

    一个逻辑表达式(logic expression)用字母和门的词书写一个电路。书写门的通常方式:

    用词
    NOT A NOT A
    A AND B A AND B
    A OR B A OR B

    例如,表达式 (A AND B) OR (NOT C) 意味着:做 A AND B、做 NOT C,然后把两个结果 OR 在一起。

    表达式 X 等于 A AND B OR NOT C 画成一个电路:一个 AND 门取 A 和 B、一个 NOT 门取 C,而一个 OR 门把两个组合成输出 X
    表达式 X = (A AND B) OR (NOT C) 画成一个逻辑电路
    探索

    Truth tables

    Build the truth table for AND, OR, XOR and NOT — the logic behind every expression.

    词汇表 训练
    英文 中文 拼音
    logic expression 逻辑表达式 luó jí biǎo dá shì
    10.4

    逻辑电路

    一个逻辑电路(logic circuit)把门连接在一起以执行一个任务。一个门的输出能变成另一个的输入。在 IGCSE,一个电路有多达三个输入一个输出

    一个逻辑电路:一个取输入 A 和 B 的 AND 门馈送一个 OR 门的一个输入,OR 门的另一个输入是 C,给出输出 X
    为 X = (A AND B) OR C 构建电路——AND 门的输出馈送 OR 门

    你必须能在四种形式之间移动:

    • 一个问题陈述(problem statement,一个用词的描述),
    • 一个逻辑表达式,
    • 一个逻辑电路,
    • 一个真值表。

    From a problem statement to a circuit

    读陈述并挑出条件和逻辑词(and、or、not)。例如:

    一个警报(X)在门开着(A)AND 系统被打开(B)时响起。

    这是 X = A AND B,所以你画一个 AND 门,带输入 A 和 B。

    Completing a truth table from a circuit or expression

    要填一个真值表:

    1. 所有输入组合。对三个输入有 8 行(000 到 111)。
    2. 按顺序算出每个门的输出,一次一列。
    3. 最后一列是最终输出。
    三个输入给二乘二乘二等于八行;八个组合通过从 000 到 111 用二进制往上数列出,最后一列翻转每一行
    三个输入给八行:每个组合以二进制计数
    A B C A AND B (A AND B) OR C
    0 0 0 0 0
    0 0 1 0 1
    0 1 0 0 0
    0 1 1 0 1
    1 0 0 0 0
    1 0 1 0 1
    1 1 0 1 1
    1 1 1 1 1

    为每个门加一个中间的"工作"列使最终输出容易填。总是精确地按陈述所说画电路,不简化它。

    例题。X = (A AND B) OR (NOT C),完成 A = 1、B = 0、C = 0 这一行的真值表。从括号往外做,一次算一个门。首先 A AND B = 1 AND 0 = 0,因为 AND 要求两个输入都是 1。接着 NOT C = NOT 0 = 1。最后把两个结果做 OR:0 OR 1 = 1。所以 X = 1。要给每个中间的门单独一列,而不是想一步算完整个表达式:三个输入意味着有 $2^3 = 8$ 行,而这些中间列正是即使最终答案算错也能拿到方法分的地方。

    词汇表 训练
    英文 中文 拼音
    logic circuit 逻辑电路 luó jí diàn lù
    problem statement 问题陈述 wèn tí chén shù
    10.5

    考试技巧

    • 学习所有六个门及它们的真值表:NOTANDORNAND(NOT AND)、NOR(NOT OR)、XOR(在输入不同时输出 1)。
    • 所有输入行构建一个真值表(2 个输入 → 4 行,3 个输入 → 8),以二进制往上数,并为每个门加一个工作列。
    • 通过挑出 AND / OR / NOT 词把一个问题陈述变成一个逻辑表达式,然后精确地按书写画它——不要简化它。
    • NAND 和 NOR 给出与 AND 和 OR 相反的输出;一个门输出上的一个小圆圈意味着结果被反转。

登录或创建账号

IGCSE, A-Level & AP