📚 GCSE CIE Computer Science: Calculation Practice Drills | GCSE CIE 计算机:计算题专项训练
Calculation-based questions form an essential part of the CIE IGCSE Computer Science examination. This guide covers the most common types of numerical problems you will encounter, from number system conversions to file size estimations and error detection. Step-by-step examples and key formulas are provided to help you master each topic.
计算题是 CIE IGCSE 计算机科学考试的重要组成部分。本指南涵盖了最常见的数值类问题,包括数制转换、文件大小估算和错误检测等。文中提供了分步示例和关键公式,帮助你掌握每个主题。
1. Binary to Decimal Conversion | 二进制转换为十进制
Binary numbers are written in base-2, using only the digits 0 and 1. Each digit’s place represents an increasing power of 2, starting from 2⁰ on the rightmost side.
二进制数以 2 为基数,只使用数字 0 和 1。每个数位代表一个递增的 2 的幂,从最右侧的 2⁰ 开始。
To convert a binary number to decimal, multiply each binary digit by its corresponding place value and add all the results together.
要将二进制数转换为十进制,将每个二进制数字乘以其对应的位权,然后将所有结果相加。
Example: Convert 101101₂ to decimal. The place values from left to right are 32, 16, 8, 4, 2, 1.
示例:将 101101₂ 转换为十进制。位权从左到右依次为 32、16、8、4、2、1。
101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 0 + 8 + 4 + 0 + 1 = 45₁₀
2. Decimal to Binary Conversion | 十进制转换为二进制
The most reliable method for converting a decimal number to binary is repeated division by 2. You write down the remainders in reverse order to obtain the binary equivalent.
将十进制数转换为二进制的最可靠方法是除以 2 取余法。将余数按逆序排列即可得到对应的二进制数。
Divide the decimal number by 2, record the remainder (0 or 1), and continue dividing the quotient by 2 until the quotient becomes 0. The binary number is the sequence of remainders read from bottom to top.
将十进制数除以 2,记录余数(0 或 1),然后继续用商除以 2,直到商为 0。从下往上读取余数序列,即为二进制数。
Example: Convert 78₁₀ to binary.
示例:将 78₁₀ 转换为二进制。
| Division by 2 | Quotient | Remainder |
|---|---|---|
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from bottom to top gives 1001110₂. Therefore, 78₁₀ = 1001110₂.
从下往上读取余数,得到 1001110₂。因此,78₁₀ = 1001110₂。
3. Hexadecimal Conversions | 十六进制转换
Hexadecimal (base-16) uses digits 0–9 and letters A–F, where A=10, B=11, …, F=15. It is often used to represent binary values compactly because one hex digit corresponds to exactly four binary bits (a nibble).
十六进制(基数为 16)使用数字 0–9 和字母 A–F,其中 A=10,B=11,……,F=15。由于一个十六进制数字恰好对应四位二进制位(半字节),因此常被用来紧凑地表示二进制值。
To convert binary to hexadecimal, split the binary number into groups of four bits starting from the right, then convert each group to its hex equivalent. If the leftmost group has fewer than four bits, pad with leading zeros.
要将二进制转换为十六进制,从右边开始将二进制数每四位分成一组,然后将每组转换为其等价的十六进制值。如果最左侧一组不足四位,则在前面补零。
Example: Convert 110101110₂ to hex. Group as 0001 1010 1110 → 1 A E, so the answer is 1AE₁₆ (often written as 0x1AE).
示例:将 110101110₂ 转换为十六进制。分组为 0001 1010 1110 → 1 A E,因此结果为 1AE₁₆(常写作 0x1AE)。
To convert hex to decimal, multiply each digit by its place value (powers of 16). For instance, 2F₁₆ = 2×16¹ + 15×16⁰ = 32 + 15 = 47₁₀.
要将十六进制转换为十进制,将每个数字乘以其位权(16 的幂)。例如,2F₁₆ = 2×16¹ + 15×16⁰ = 32 + 15 = 47₁₀。
4. Binary Addition and Overflow | 二进制加法和溢出
Binary addition follows similar rules to decimal addition but carries occur when the sum of two bits reaches 2 (binary 10). The key rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 carry 1, and 1+1+carry=1 carry 1.
二进制加法遵循与十进制加法类似的规则,但当两个位之和达到 2(即二进制 10)时会产生进位。基本规则为:0+0=0,0+1=1,1+0=1,1+1=0 进位 1,1+1+进位=1 进位 1。
Example: Add 0110₂ (6) and 0111₂ (7). Working from right to left: 0+1=1, 1+1=0 carry 1, 1+1+1=1 carry 1, 0+0+1=1. Result: 1101₂ (13).
示例:将 0110₂(6)和 0111₂(7)相加。从右向左运算:0+1=1,1+1=0 进位 1,1+1+1=1 进位 1,0+0+1=1。结果为 1101₂(13)。
Overflow occurs when the result of an addition requires more bits than the fixed bit-width can hold. For example, in 4-bit addition, 1001₂ + 1000₂ would produce a 5-bit result (10001₂), but the leftmost bit is lost, leaving an incorrect value. In exams, you must recognise when a carry out of the most significant bit indicates an overflow error.
当加法结果所需的位数超出固定位宽时,就会发生溢出。例如,在 4 位加法中,1001₂ + 1000₂ 会产生一个 5 位结果(10001₂),但最左侧的位会丢失,留下错误的值。在考试中,你必须能够识别最高位的进位何时表示溢出错误。
5. Logic Gates and Truth Tables | 逻辑门与真值表
Logic gates process binary inputs and produce a single output. The fundamental gates are NOT, AND, OR, NAND, NOR, and XOR. You need to be able to complete truth tables and predict outputs for given input combinations.
逻辑门处理二进制输入并产生单个输出。基本门电路包括 NOT、AND、OR、NAND、NOR 和 XOR。你需要能够填写真值表,并根据给定的输入组合预测输出。
For an AND gate, the output is 1 only when all inputs are 1. For an OR gate, the output is 1 if at least one input is 1. NAND is the opposite of AND, and NOR is the opposite of OR. XOR gives 1 when an odd number of inputs are 1.
对于 AND 门,只有当所有输入都为 1 时,输出才为 1。对于 OR 门,如果至少有一个输入为 1,则输出为 1。NAND 是 AND 的相反,NOR 是 OR 的相反。当输入中 1 的个数为奇数时,XOR 输出 1。
Example: Complete the truth table for a 2-input NAND gate.
示例:完成一个两输入 NAND 门的真值表。
| A | B | Output (A NAND B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
In exam questions, you may be given a combination of gates and asked to find the final output for a set of inputs. Trace the signal through each gate step by step.
在考试题目中,你可能会遇到多个门电路的组合,并被要求求出一组输入下的最终输出。这时需要按顺序逐步追踪每个门的信号。
6. Logic Circuits to Boolean Expressions | 逻辑电路转换为布尔表达式
A logic circuit diagram can be expressed as a Boolean expression using standard notation: A AND B is written as A·B or A∧B, A OR B as A+B or A∨B, and NOT A as ¬A or an overbar (A̅).
逻辑电路图可以用标准记法表示为布尔表达式:A AND B 写作 A·B 或 A∧B,A OR B 写作 A+B 或 A∨B,NOT A 写作 ¬A 或上划线 (A̅)。
To derive the expression, work from the input side to the output, writing the operation at each gate. For example, if inputs A and B feed into an AND gate, and its output goes to a NOT gate, the overall expression is ¬(A·B), which is the same as a NAND gate.
为了推导表达式,从输入端向输出端逐级写出每个门的运算。例如,若输入 A 和 B 进入一个 AND 门,其输出又进入一个 NOT 门,则整体表达式为 ¬(A·B),这等同于一个 NAND 门。
Be prepared to evaluate the Boolean expression for given binary values. For instance, if A=1, B=0, C=1, evaluate (A·B)+C. Substituting: (1·0)+1 = 0+1 = 1.
准备好对给定的二进制值计算布尔表达式。例如,若 A=1,B=0,C=1,计算 (A·B)+C。代入得:(1·0)+1 = 0+1 = 1。
7. File Size Calculations: Text, Image and Sound | 文件大小计算:文本、图像和声音
Calculating file sizes is a common practical task. Understanding the formula for each data type is crucial.
计算文件大小是一项常见的实用任务。了解每种数据类型的计算公式至关重要。
Text: Each character is typically stored using an encoding such as ASCII (7 or 8 bits per character) or Unicode (16 bits). The file size in bits = number of characters × bits per character. Remember that 1 byte = 8 bits.
文本:每个字符通常使用 ASCII(每字符 7 或 8 位)或 Unicode(16 位)等编码存储。文件大小(位)= 字符数 × 每字符位数。请记住 1 字节 = 8 位。
Example: A text file contains 200 ASCII characters using 8-bit encoding. Size = 200 × 8 = 1600 bits = 200 bytes. If the same text used Unicode (16-bit), the size would double to 400 bytes.
示例:一个文本文件包含 200 个使用 8 位编码的 ASCII 字符。大小 = 200 × 8 = 1600 位 = 200 字节。如果同样的文本使用 Unicode(16 位),大小将加倍至 400 字节。
Image: An image is made up of pixels. Each pixel’s colour is represented by a binary number; the number of bits per pixel is the colour depth. The image size in bits = width in pixels × height in pixels × colour depth. For higher resolutions or greater colour depth, the file size increases.
图像:图像由像素组成。每个像素的颜色由二进制数表示;每像素位数即为颜色深度。图像大小(位)= 宽度(像素)× 高度(像素)× 颜色深度。分辨率越高或颜色深度越大,文件大小就越大。
Example: A 1024 × 768 image with 24-bit colour. Total bits = 1024 × 768 × 24 = 18,874,368 bits. Convert to bytes: ÷8 = 2,359,296 B, then ÷1024 ≈ 2304 KB, ÷1024 ≈ 2.25 MB.
示例:一张 1024 × 768、24 位颜色的图像。总位数 = 1024 × 768 × 24 = 18,874,368 位。转换为字节:÷8 = 2,359,296 字节,然后 ÷1024 ≈ 2304 KB,再 ÷1024 ≈ 2.25 MB。
Sound: Digital sound is created by sampling an analogue signal. The file size depends on the sample rate (Hz), bit depth (bits), duration (seconds) and number of channels (1 for mono, 2 for stereo). The formula: size in bits = sample rate × bit depth × duration × channels.
声音:数字声音通过对模拟信号进行采样生成。文件大小取决于采样率(Hz)、位深度(位)、时长(秒)和声道数(单声道为 1,立体声为 2)。公式:大小(位)= 采样率 × 位深度 × 时长 × 声道数。
Example: 10 seconds of stereo audio recorded at 44.1 kHz with 16-bit samples. Bits = 44,100 × 16 × 10 × 2 = 14,112,000 bits. In megabytes: 14,112,000 ÷ 8 = 1,764,000 bytes; ÷1024 ≈ 1722.7 KB; ÷1024 ≈ 1.68 MB.
示例:一段 10 秒、44.1 kHz、16 位采样的立体声音频。位数 = 44,100 × 16 × 10 × 2 = 14,112,000 位。以 MB 表示:14,112,000 ÷ 8 = 1,764,000 字节;÷1024 ≈ 1722.7 KB;÷1024 ≈ 1.68 MB。
8. Data Transmission Time | 数据传输时间计算
The time needed to transmit a file across a network can be calculated by dividing the file size by the data transfer rate. Always ensure units are consistent—if the rate is in bits per second (bps), the file size must also be in bits.
通过网络传输文件所需的时间可以通过文件大小除以数据传输速率来计算。务必确保单位一致——如果速率用比特每秒(bps)表示,文件大小也必须以比特为单位。
Formula: time (seconds) = file size (bits) / transfer rate (bps). Common units include kbps (×1000), Mbps (×1000²) and Gbps (×1000³). Note that in data communication, 1 kbps = 1000 bps, unlike storage where 1 KB = 1024 B.
公式:时间(秒)= 文件大小(位)÷ 传输速率(bps)。常见单位包括 kbps(×1000)、Mbps(×1000²)和 Gbps(×1000³)。请注意,在数据通信中,1 kbps = 1000 bps,这与存储中 1 KB = 1024 B 不同。
Example: A 2 MB file (where 1 MB = 1024 × 1024 × 8 bits) is uploaded over a 2 Mbps connection. File size in bits = 2 × 1024 × 1024 × 8 = 16,777,216 bits. Transfer rate = 2 × 10⁶ bps = 2,000,000 bps. Time = 16,777,216 ÷ 2,000,000 ≈ 8.39 seconds.
示例:一个 2 MB 的文件(设 1 MB = 1024 × 1024 × 8 位)通过 2 Mbps 的连接上传。文件大小(位)= 2 × 1024 × 1024 × 8 = 16,777,216 位。传输速率 = 2 × 10⁶ bps = 2,000,000 bps。时间 = 16,777,216 ÷ 2,000,000 ≈ 8.39 秒。
9. Error Detection: Parity Bits and Checksums | 错误检测:奇偶校验位与校验和
Parity bits and checksums are used to detect errors during data transmission or storage. A parity bit is an extra bit added to a binary string to make the total number of 1s either even (even parity) or odd (odd parity).
奇偶校验位和校验和用于检测数据传输或存储过程中的错误。奇偶校验位是在二进制串中添加的一个额外位,使 1 的总数变为偶数(偶校验)或奇数(奇校验)。
Even parity calculation: count the number of 1s in the data. If the count is odd, set the parity bit to 1 to make the total even; if it is already even, set the parity bit to 0. For example, byte 10110010 has four 1s, which is even, so the even parity bit would be 0.
偶校验计算:统计数据中 1 的个数。如果个数为奇数,则将校验位设为 1,使总数变为偶数;如果已是偶数,则将校验位设为 0。例如,字节 10110010 中有四个 1,已为偶数,因此偶校验位为 0。
A checksum is a simple value calculated by summing data blocks (often bytes) and adding the result modulo a fixed value, such as 256. The receiver performs the same calculation and compares the result. A mismatch indicates an error.
校验和是一种简单值,通过对数据块(通常是字节)求和并将结果取模一个固定值(如 256)来计算。接收方执行相同的计算并比较结果。不匹配则表示存在错误。
Example: Data bytes: 75, 124, 38. Sum = 75+124+38 = 237. Checksum modulo 256 = 237. The checksum byte 237 is sent along with the data for verification.
示例:数据字节:75,124,38。和 = 75+124+38 = 237。校验和模 256 = 237。校验和字节 237 随数据一起发送以供验证。
10. Encryption Techniques: Caesar Cipher | 加密技术:凯撒密码
The Caesar cipher is a simple substitution cipher used as an introduction to encryption. Each letter in the plain text is shifted a fixed number of positions down the alphabet. CIE exam questions often ask you to encrypt or decrypt a short word using a given shift key.
凯撒密码是一种简单的替换密码,常被用来介绍加密概念。明文中的每个字母都按照固定数目在字母表中向后移位。CIE 考试题目通常会要求你使用给定的移位密钥对一个短单词进行加密或解密。
Encryption process: Choose a shift value, e.g., 3. Then ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, … ‘X’ becomes ‘A’, ‘Y’ becomes ‘B’, ‘Z’ becomes ‘C’. Decryption simply shifts backwards by the same amount.
加密过程:选择一个移位值,例如 3。则 ‘A’ 变成 ‘D’,’B’ 变成 ‘E’,…… ‘X’ 变成 ‘A’,’Y’ 变成 ‘B’,’Z’ 变成 ‘C’。解密只需向后移位相同的量。
Example (shift 5): Encrypt ‘HELLO’. H→M, E→J, L→Q, L→Q, O→T, giving ‘MJQQT’. To decrypt, shift each letter backwards by 5 positions.
示例(移位 5):加密 ‘HELLO’。H→M,E→J,L→Q,L→Q,O→T,得到 ‘MJQQT’。要解密,将每个字母向后移位 5 个位置。
Be careful with alphabetic wrap-around. When the shift goes past ‘Z’, it continues from ‘A’. The same logic applies to both uppercase and lowercase letters, but exam questions usually use uppercase only.
注意字母表的回绕。当移位超过 ‘Z’ 时,会从 ‘A’ 继续。同样的逻辑适用于大写和小写字母,但考试题目通常只使用大写字母。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导