📚 GCSE CIE Computer Science: Typical Example Questions Explained | GCSE CIE 计算机:典型例题详解
This article walks you through a carefully selected set of typical GCSE CIE Computer Science example questions, covering core topics from data representation and logic to algorithms, networks and programming. Each worked example is fully explained, showing the logical steps, common pitfalls and the reasoning behind correct answers. Use this as a revision checkpoint to test your understanding and sharpen your exam technique.
本文带你逐题精讲一组典型的 GCSE CIE 计算机科学例题,涵盖数据表示、逻辑、算法、网络和编程等核心主题。每一道例题都配有详细解析,展示推理步骤、常见错误和正确答案背后的逻辑。把本文当作复习自测站,助你查漏补缺,提升应试技巧。
1. Binary and Hexadecimal Conversion | 二进制与十六进制转换
Question: Convert the decimal number 200 into an 8-bit binary number, then express that binary value in hexadecimal. Show all your working.
问题:将十进制数 200 转换为 8 位二进制数,再将该二进制值表示为十六进制。请展示所有演算过程。
Step 1: Repeatedly divide 200 by 2, recording the remainder each time until the quotient is 0.
步骤 1:不断用 200 除以 2,记录每次余数,直到商为 0。
200 ÷ 2 = 100 remainder 0
200 ÷ 2 = 100 余 0
100 ÷ 2 = 50 remainder 0
100 ÷ 2 = 50 余 0
50 ÷ 2 = 25 remainder 0
50 ÷ 2 = 25 余 0
25 ÷ 2 = 12 remainder 1
25 ÷ 2 = 12 余 1
12 ÷ 2 = 6 remainder 0
12 ÷ 2 = 6 余 0
6 ÷ 2 = 3 remainder 0
6 ÷ 2 = 3 余 0
3 ÷ 2 = 1 remainder 1
3 ÷ 2 = 1 余 1
1 ÷ 2 = 0 remainder 1
1 ÷ 2 = 0 余 1
Step 2: Read the remainders from bottom to top to form the binary number: 11001000. This is already 8 bits, so we can write it as 11001000.
步骤 2:从下往上读取余数,得到二进制数 11001000。它恰好是 8 位,因此可记作 11001000。
Step 3: To convert to hexadecimal, group the binary digits into nibbles of four starting from the right: 1100 1000.
步骤 3:为转换为十六进制,从右起每 4 位分为一组:1100 1000。
1100₂ = 12₁₀ = C₁₆ and 1000₂ = 8₁₀ = 8₁₆.
1100₂ = 12₁₀ = C₁₆,1000₂ = 8₁₀ = 8₁₆。
Therefore, 11001000₂ = C8₁₆. The decimal 200 equals C8 in hexadecimal.
因此,11001000₂ = C8₁₆。十进制 200 的十六进制形式为 C8。
2. Logic Gates and Truth Tables | 逻辑门与真值表
Question: A logic circuit has inputs A, B and C. A and B are connected to an AND gate whose output is one input to an OR gate. The other input of the OR gate is C. The final output is Q. Draw the truth table for Q.
问题:某逻辑电路有输入 A、B 和 C。A 与 B 接至一个与门,其输出作为或门的一个输入;或门的另一个输入为 C。最终输出为 Q。请给出 Q 的真值表。
First, compute the AND gate output: X = A AND B. Then Q = X OR C.
首先计算与门输出:X = A AND B。然后 Q = X OR C。
| A | B | C | X = A AND B | Q = X 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 |
Note that Q is 1 whenever C is 1 or when both A and B are 1. This matches the behaviour of the circuit.
注意,只要 C 为 1 或 A 与 B 同时为 1,Q 就为 1。这与电路行为一致。
3. Pseudocode Trace Table | 伪代码追踪
Question: What is the output of the following pseudocode? Show a trace table.
问题:以下伪代码的输出是什么?请用追踪表展示。
total ← 0FOR i ← 1 TO 5 total ← total + i * iENDFOROUTPUT total
total ← 0FOR i ← 1 TO 5 total ← total + i * iENDFOROUTPUT total
We track the values loop by loop.
我们逐次循环追踪数值。
i = 1: i*i = 1, total becomes 0 + 1 = 1
i = 1: i*i = 1, total 变为 0 + 1 = 1
i = 2: i*i = 4, total becomes 1 + 4 = 5
i = 2: i*i = 4, total 变为 1 + 4 = 5
i = 3: i*i = 9, total becomes 5 + 9 = 14
i = 3: i*i = 9, total 变为 5 + 9 = 14
i = 4: i*i = 16, total becomes 14 + 16 = 30
i = 4: i*i = 16, total 变为 14 + 16 = 30
i = 5: i*i = 25, total becomes 30 + 25 = 55
i = 5: i*i = 25, total 变为 30 + 25 = 55
After the loop ends, the program outputs 55. The final answer is 55.
循环结束后,程序输出 55。最终答案是 55。
4. Bubble Sort Walkthrough | 冒泡排序逐步演算
Question: Perform a bubble sort on the list [4, 2, 8, 1, 5] to arrange it in ascending order. Show the state of the list after each pass.
问题:对列表 [4, 2, 8, 1, 5] 执行冒泡排序,按升序排列。请展示每一遍扫描后列表的状态。
Pass 1: Compare and swap adjacent elements from left to right.
第一遍:从左到右比较并交换相邻元素。
Compare 4 and 2 – swap → [2, 4, 8, 1, 5]; compare 4 and 8 – no swap; compare 8 and 1 – swap → [2, 4, 1, 8, 5]; compare 8 and 5 – swap → [2, 4, 1, 5, 8]. End of pass 1: largest element 8 is at the end.
比较 4 与 2 – 交换 → [2, 4, 8, 1, 5];比较 4 与 8 – 不交换;比较 8 与 1 – 交换 → [2, 4, 1, 8, 5];比较 8 与 5 – 交换 → [2, 4, 1, 5, 8]。第一遍结束:最大元素 8 已归位。
Pass 2: Repeat for the first four elements [2, 4, 1, 5, 8] – 8 is already in place.
第二遍:对前四个元素 [2, 4, 1, 5, 8] 重复操作(8 已就位)。
Compare 2 and 4 – no swap; compare 4 and 1 – swap → [2, 1, 4, 5, 8]; compare 4 and 5 – no swap; compare 5 and 8 – no swap. After pass 2: [2, 1, 4, 5, 8].
比较 2 与 4 – 不交换;比较 4 与 1 – 交换 → [2, 1, 4, 5, 8];比较 4 与 5 – 不交换;比较 5 与 8 – 不交换。第二遍后:[2, 1, 4, 5, 8]。
Pass 3: Work on [2, 1, 4, 5] – 5 and 8 are sorted.
第三遍:处理 [2, 1, 4, 5](5 和 8 已排好)。
Compare 2 and 1 – swap → [1, 2, 4, 5, 8]; compare 2 and 4 – no swap; compare 4 and 5 – no swap. Pass 3 yields [1, 2, 4, 5, 8]. The list is now sorted, so no more passes are needed.
比较 2 与 1 – 交换 → [1, 2, 4, 5, 8];比较 2 与 4 – 不交换;比较 4 与 5 – 不交换。第三遍得到 [1, 2, 4, 5, 8]。列表已有序,无需更多遍。
5. Parity Bit and Error Detection | 奇偶校验位与错误检测
Question: A system uses even parity with the parity bit placed as the most significant bit. The 7-bit data to be transmitted is 1011001. What is the full 8-bit value sent?
问题:某系统采用偶校验,校验位放在最高有效位。待传输的 7 位数据为 1011001。发送的完整 8 位值是什么?
Count the number of 1s in 1011001: bit positions show 1, 0, 1, 1, 0, 0, 1 → there are four 1s (an even number).
先计算 1011001 中 1 的个数:位依次为 1, 0, 1, 1, 0, 0, 1 → 共有四个 1(偶数个)。
With even parity, the parity bit must make the total number of 1s in the whole byte even. Since there are already four 1s, the parity bit should be 0. Place it at the front: 0 1011001 → 01011001.
偶校验要求整个字节中 1 的总数为偶数。因为已有 4 个 1,校验位应为 0。将其放在最前面:0 1011001 → 01011001。
The transmitted byte is 01011001. If a single bit flips during transmission, the number of 1s will become odd and the error can be detected.
发送的字节是 01011001。若传输中某一比特翻转,1 的个数将变为奇数,错误即可被检测到。
6. IP and MAC Addresses in Networking | 网络中的 IP 与 MAC 地址
Question: Explain why data packets require both an IP address and a MAC address when travelling across the internet, and describe how these addresses are used at each hop.
问题:解释数据包在互联网上传输时为什么需要 IP 地址和 MAC 地址,并描述在每一跳中这些地址如何被使用。
An IP address is a logical address that identifies a device’s network and host on the internet. It remains the same from source to destination so routers can forward the packet towards the correct network.
IP 地址是一个逻辑地址,标示设备在互联网中的网络和主机。从源到目的地它保持不变,因此路由器能将数据包转发到正确的网络。
A MAC address is a physical hardware address burned into a network interface card. It is used for communication within a local network segment (LAN).
MAC 地址是烧录在网卡上的物理硬件地址,用于本地网段(LAN)内部的通信。
At each hop, a router strips the incoming source and destination MAC addresses and replaces them with the MAC addresses of the current router interface and the next hop device. The source and destination IP addresses, however, remain unchanged, ensuring the packet can be delivered end-to-end.
每一跳中,路由器会剥去传入的源与目的 MAC 地址,并用当前路由器接口及下一跳设备的 MAC 地址替换。但源与目的 IP 地址保持不变,从而保证数据包能端到端交付。
This combination allows global addressing (IP) and local delivery (MAC) to work together efficiently.
这种组合使得全局寻址(IP)与本地投递(MAC)高效协同。
7. SQL Query on a Database Table | 数据库表 SQL 查询
Question: A table Student has fields ID, Name, Age and Grade. Write an SQL query to retrieve the Name and Age of all students older than 15.
问题:表 Student 包含字段 ID, Name, Age 和 Grade。写出一条 SQL 查询以检索所有年龄大于 15 岁的学生姓名和年龄。
The required SQL statement is:
所需 SQL 语句为:
SELECT Name, Age FROM Student WHERE Age > 15;
SELECT Name, Age FROM Student WHERE Age > 15;
SELECT specifies the columns to display, FROM identifies the table, and WHERE filters rows based on the condition Age > 15.
SELECT 指定要显示的列,FROM 指明表,WHERE 根据条件 Age > 15 筛选行。
Only those records where the Age field holds a value greater than 15 will be included in the resulting temporary table.
只有 Age 字段值大于 15 的记录才会出现在临时结果表中。
If we wanted all columns, we could write SELECT * FROM Student WHERE Age > 15; but the question specifically asked for Name and Age only.
若需所有列,可写 SELECT * FROM Student WHERE Age > 15; 但问题明确只要求 Name 和 Age。
8. Python Code Error Correction | Python 代码错误修正
Question: The following Python function is intended to calculate and return the area of a circle given its radius, but contains several errors. Identify and correct them, then state the output for radius = 5.
问题:以下 Python 函数旨在计算并返回给定半径的圆面积,但包含几处错误。找出并修正错误,然后说明半径 = 5 时的输出。
def calculate_area(radius)area = 3.14 * radius * radiusreturn areaprint(calculate_area(5))
def calculate_area(radius)area = 3.14 * radius * radiusreturn areaprint(calculate_area(5))
Error 1: The function definition line is missing a colon at the end. Correct to def calculate_area(radius):
错误 1:函数定义行末尾缺少冒号。应改为 def calculate_area(radius):
Error 2: The statements inside the function body are not indented. Python requires consistent indentation. The lines area = … and return area should be indented, typically by four spaces.
错误 2:函数体内的语句未缩进。Python 要求一致的缩进。area = … 及 return area 两行应缩进,通常为四个空格。
Corrected code:
修正后的代码:
def calculate_area(radius): area = 3.14 * radius * radius return areaprint(calculate_area(5))
def calculate_area(radius): area = 3.14 * radius * radius return areaprint(calculate_area(5))
Execution: calculate_area(5) computes 3.14 × 5 × 5 = 78.5. The function returns 78.5, and print outputs 78.5.
执行过程:calculate_area(5) 计算 3.14 × 5 × 5 = 78.5。函数返回 78.5,print 输出 78.5。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply