IB WJEC Computer Science: Laboratory Practical Guide | IB WJEC 计算机:实验操作指南

📚 IB WJEC Computer Science: Laboratory Practical Guide | IB WJEC 计算机:实验操作指南

This guide provides step-by-step instructions for conducting practical experiments in IB and WJEC Computer Science. You will learn how to set up environments, implement algorithms, test systems, and document findings, aligning with internal assessment (IA) requirements and exam board criteria.

本指南为 IB 和 WJEC 计算机科学课程的实验操作提供分步说明。你将学习如何搭建环境、实现算法、测试系统并记录结果,符合内部评估 (IA) 要求和考试局标准。

1. Setting Up the Development Environment | 搭建开发环境

Begin by installing the appropriate Integrated Development Environment (IDE) and compiler or interpreter for your chosen language, such as Python 3.10+ with IDLE or VS Code, or Java with IntelliJ IDEA. Ensure that all necessary libraries (e.g. ‘sqlite3’, ‘tkinter’) are available.

首先安装合适的集成开发环境 (IDE) 以及所选语言的编译器或解释器,例如 Python 3.10+ 搭配 IDLE 或 VS Code,或者 Java 搭配 IntelliJ IDEA。确保所有必要的库(如 ‘sqlite3’、’tkinter’)已就绪。

Create a dedicated folder structure for each experiment: /lab1_algorithm, /lab2_database, and subfolders for source code, data files, and documentation. Use a version control system like Git to track changes, even for solo work, as it builds good practice for the IA.

为每个实验创建专用文件夹结构:/lab1_algorithm、/lab2_database,以及用于源代码、数据文件与文档的子文件夹。使用 Git 等版本控制系统跟踪变更,即使是单人工作,这也能为 IA 培养良好习惯。

Verify your setup by writing a “Hello World” program and confirming output. For Java, this validates the JDK installation; for Python, check that ‘python –version’ returns the correct number in the terminal.

通过编写”Hello World”程序并确认输出来验证环境。对于 Java,这将验证 JDK 安装;对于 Python,请检查终端中 ‘python –version’ 是否返回正确的版本号。


2. Algorithm Design and Implementation | 算法设计与实现

Start by understanding the problem: identify inputs, processes, and outputs. Write pseudocode in a structured format, using keywords like INPUT, WHILE, IF…THEN…ELSE, and OUTPUT. For example, a linear search algorithm pseudocode lists each comparison step explicitly.

首先理解问题:确定输入、处理过程和输出。使用结构化格式编写伪代码,使用 INPUT、WHILE、IF…THEN…ELSE 和 OUTPUT 等关键字。例如,线性搜索算法伪代码明确列出每次比较步骤。

Translate pseudocode into a high-level language. In Python, a linear search function might use a ‘for’ loop and a flag variable. In Java, implement the same logic with a ‘boolean found’ variable. Test with both typical and edge-case data: an empty array, the target at the first position, and the target absent.

将伪代码翻译成高级语言。在 Python 中,线性搜索函数可能使用 ‘for’ 循环和标志变量。在 Java 中,使用 ‘boolean found’ 变量实现相同逻辑。用典型数据和边缘情况测试:空数组、目标在第一个位置以及目标不存在。

Analyse time complexity. For linear search, the worst-case complexity is O(n). For binary search on a sorted array, it is O(log n). Record these using standard notation: O(1), O(n), O(n²), O(log n), O(2ⁿ).

分析时间复杂度。对于线性搜索,最坏情况复杂度为 O(n)。对于有序数组的二分搜索,复杂度为 O(log n)。使用标准符号记录:O(1)、O(n)、O(n²)、O(log n)、O(2ⁿ)。

  • Linear search: O(n)
  • Binary search: O(log n)
  • Bubble sort: O(n²)
  • Merge sort: O(n log n)

线性搜索:O(n);二分搜索:O(log n);冒泡排序:O(n²);归并排序:O(n log n)。


3. Data Structures in Practice | 数据结构实践

Implement a stack using an array or linked list. For an array-based stack, track a ‘top’ index and provide push (add to top+1) and pop (return top and top-1) operations. Test with a sequence of pushes and pops, checking for underflow and overflow conditions.

使用数组或链表实现栈。对于基于数组的栈,跟踪 ‘top’ 索引,并提供 push(添加到 top+1)和 pop(返回 top 并将 top-1)操作。用一系列 push 和 pop 操作进行测试,检查下溢和上溢条件。

Build a queue with circular array implementation. Maintain ‘front’ and ‘rear’ pointers, and use modulo arithmetic for wrap-around. Enqueue and dequeue items, verifying FIFO (first-in-first-out) behaviour by printing the queue after each operation.

用循环数组实现构建队列。维护 ‘front’ 和 ‘rear’ 指针,并使用模运算实现环绕。入队和出队项目,通过在每次操作后打印队列来验证 FIFO(先进先出)行为。

Experiment with linked lists: create a singly linked list where each node holds data and a ‘next’ reference. Write methods to insert at head, insert at tail, and delete a node by value. Draw memory diagrams to illustrate pointer changes.

实验链表:创建一个单链表,其中每个节点包含数据和 ‘next’ 引用。编写在头部插入、在尾部插入以及按值删除节点的方法。绘制内存图以说明指针变化。


4. Database Query Lab | 数据库查询实验

Design a simple relational database with at least two tables: for instance, ‘Students’ (StudentID, Name, Form) and ‘Results’ (ResultID, StudentID, Subject, Grade). Create the tables using SQL statements in SQLite or another RDBMS.

设计一个至少包含两个表的简单关系数据库:例如 ‘Students’(StudentID, Name, Form)和 ‘Results’(ResultID, StudentID, Subject, Grade)。使用 SQLite 或其他 RDBMS 中的 SQL 语句创建表。

Insert sample data: at least five students and several results per student. Ensure that some students have no results to test outer joins. Write SELECT queries with WHERE, ORDER BY, GROUP BY, and HAVING clauses.

插入示例数据:至少五名学生,每名学生多条成绩。确保一些学生没有成绩以测试外连接。编写包含 WHERE、ORDER BY、GROUP BY 和 HAVING 子句的 SELECT 查询。

Construct a parameterised query to find all students achieving a grade above a given threshold. In Python, use ‘?’ placeholders to prevent SQL injection. Document the query and result set in your lab log.

构造一个参数化查询,查找所有成绩高于给定阈值的学生。在 Python 中,使用 ‘?’ 占位符以防止 SQL 注入。在实验日志中记录查询和结果集。

Perform a JOIN operation: INNER JOIN to match students with their results, and LEFT JOIN to include students without results. Explain the output differences, linking to the concept of referential integrity.

执行 JOIN 操作:使用 INNER JOIN 匹配学生及其成绩,使用 LEFT JOIN 包含没有成绩的学生。解释输出差异,并联系参照完整性概念。


5. Networking and Communication | 网络与通信实验

Simulate a simple client-server model using sockets. Write a Python server that listens on a port, and a client that connects and sends a message. The server should echo the message back, demonstrating the request-response cycle.

使用套接字模拟简单的客户端-服务器模型。编写一个监听端口的 Python 服务器,以及一个连接并发送消息的客户端。服务器应回显消息,演示请求-响应循环。

Capture and analyse HTTP traffic with a tool like browser developer tools or Wireshark (in a controlled lab). Observe the GET request, response headers, and status codes such as 200 OK and 404 Not Found. Record the role of protocols: TCP handshake, DNS resolution.

使用浏览器开发者工具或 Wireshark(在受控实验室中)捕获并分析 HTTP 流量。观察 GET 请求、响应头以及 200 OK 和 404 Not Found 等状态码。记录协议的作用:TCP 握手、DNS 解析。

Build a simple web page that includes a form with client-side validation using JavaScript. Validate an email field to contain ‘@’ and a ‘.’ before submission. Explain how this reduces server load and improves user experience.

构建一个包含表单并使用 JavaScript 进行客户端验证的简单网页。在提交前验证电子邮件字段包含 ‘@’ 和 ‘.’。解释这如何减少服务器负载并改善用户体验。


6. Boolean Logic and Circuits | 布尔逻辑与电路实验

Derive truth tables for standard gates: AND, OR, NOT, NAND, NOR, XOR. Represent these using symbol notation. For example, A AND B yields 1 only when both inputs are 1. Build a half-adder circuit using an XOR and an AND gate, and record the truth table for Sum and Carry.

推导标准门电路的真值表:AND、OR、NOT、NAND、NOR、XOR。使用符号表示。例如,A AND B 仅当两个输入均为 1 时才输出 1。使用一个 XOR 门和一个 AND 门构建半加器电路,并记录 Sum 和 Carry 的真值表。

Simplify a Boolean expression using algebraic laws or Karnaugh maps. For instance, simplify F = A·B + A·¬B to A. Show each step, applying rules like A·1 = A and the complement law. Verify with a truth table that the simplified and original expressions match.

使用代数定律或卡诺图简化布尔表达式。例如,将 F = A·B + A·¬B 简化为 A。显示每一步,应用 A·1 = A 和互补律等规则。通过真值表验证简化后的表达式与原表达式一致。

Use a logic simulator (e.g. Logicly, or an online gate simulator) to construct and test a 2-to-4 decoder. Observe how the binary input selects an output line. Relate this to the address decoding in memory systems.

使用逻辑模拟器(如 Logicly 或在线门电路模拟器)构建并测试一个 2 至 4 译码器。观察二进制输入如何选择输出线。将此与存储器系统中的地址译码联系起来。


7. System Lifecycle and Prototyping | 系统生命周期与原型设计

Identify a small real-world problem suitable for a computational solution, such as a library book loan system. Conduct a feasibility study, noting technical, economic, and legal constraints. Create a system requirement specification using a table format.

确定一个适合计算解决方案的小型现实问题,例如图书馆图书借阅系统。进行可行性研究,记录技术、经济和法律约束。使用表格格式创建系统需求规格说明。

Requirement ID Description Priority Constraints
REQ-01 Add new book High Must use ISBN validation
REQ-02 Borrow a book High Check stock >0

需求 ID:REQ-01,描述:添加新书,优先级:高,约束:必须使用 ISBN 验证。REQ-02:借出图书,高,检查库存>0。

Develop a prototype using a rapid application development tool (such as a simple Python script with file I/O). Focus on core functionality: add, search, borrow. Collect user feedback from a peer review session and list suggested improvements.

使用快速应用开发工具(例如包含文件 I/O 的简单 Python 脚本)开发原型。专注于核心功能:添加、搜索、借阅。通过同行评审收集用户反馈,并列出建议的改进。


8. Testing and Debugging Techniques | 测试与调试技术

Apply a systematic testing strategy: unit testing for individual functions, integration testing for module interactions, and user acceptance testing. In Python, use the ‘unittest’ module; in Java, JUnit. Write test cases with both valid and invalid input data.

应用系统化测试策略:对单个函数进行单元测试,对模块交互进行集成测试,以及用户验收测试。在 Python 中,使用 ‘unittest’ 模块;在 Java 中,使用 JUnit。编写包含有效和无效输入数据的测试用例。

Use debugging tools: set breakpoints in the IDE to inspect variable values mid-execution. For a loop that incorrectly terminates, step through each iteration, watching the loop counter and condition. Keep a bug log that records the error, fix, and lesson learned.

使用调试工具:在 IDE 中设置断点,在程序执行中检查变量值。对于错误终止的循环,逐步执行每次迭代,观察循环计数器和条件。保留错误日志,记录错误、修复方法以及经验教训。

Perform boundary testing. If a program accepts age input (0–120), test with -1, 0, 1, 120, 121. Record results in a table: input, expected output, actual output, pass/fail. This aligns with exam board expectations for test data selection.

执行边界测试。如果程序接受年龄输入(0–120),测试值 -1、0、1、120、121。在表格中记录结果:输入、预期输出、实际输出、通过/失败。这与考试局对测试数据选择的预期一致。


9. Ethical, Legal and Environmental Issues | 道德、法律与环境问题

Discuss the ethical implications of data collection in your experimental prototype. For the library system, explain how patron data must be processed in accordance with the GDPR (General Data Protection Regulation) principles: lawfulness, purpose limitation, data minimisation.

讨论实验原型中数据收集的道德影响。对于图书馆系统,解释读者数据必须根据 GDPR(通用数据保护条例)原则处理:合法、目的限制、数据最小化。

Analyse the environmental impact of large-scale computing systems that a full library network would require. Calculate server energy consumption: if a server uses 500W and runs 24/7, annual energy is 500W × 24h × 365 = 4,380,000 Wh = 4,380 kWh. Propose green IT strategies, such as virtualisation and power management.

分析完整图书馆网络所需的大规模计算系统对环境的影响。计算服务器能耗:如果一台服务器使用 500W 并 24/7 运行,年能耗为 500W × 24h × 365 = 4,380,000 Wh = 4,380 kWh。提出绿色 IT 策略,例如虚拟化和电源管理。

Address intellectual property: code snippets used from open-source libraries must comply with their licences (MIT, GPL). Include proper attribution in your source code header comments. Explain the legal risks of using unlicensed software for the experiment.

处理知识产权问题:从开源库使用的代码片段必须遵守其许可证(MIT、GPL)。在源代码头部注释中加入适当的归属说明。解释在实验中使用未授权软件的法律风险。


10. Writing a Comprehensive Lab Report | 撰写综合实验报告

Structure your lab report with standard sections: Title, Abstract, Introduction, Methodology, Results, Discussion, Conclusion, and References. The abstract should succinctly state the experiment’s aim, key findings, and significance in 150-200 words.

按照标准章节结构撰写实验报告:标题、摘要、引言、方法、结果、讨论、结论和参考文献。摘要应用 150-200 词简洁陈述实验目的、主要发现和意义。

In the methodology, describe your experimental design with enough detail for replication. For the algorithm lab, include the pseudocode, the test data sets used, and the environment specifications. Use the past tense and passive voice where appropriate.

在方法部分,详细描述实验设计以便他人复现。对于算法实验,包括伪代码、使用的测试数据集以及环境规格说明。适当使用过去式和被动语态。

Present results with clear data visualisation: use tables for truth tables and time measurements, and line charts for performance comparisons. For complexity analysis, include a graph plotting input size (n) against execution time, with a trend line indicating O(n²) or O(n log n) fit.

使用清晰的数据可视化呈现结果:真值表和时间测量使用表格,性能比较使用折线图。对于复杂度分析,包含绘制输入规模 (n) 与执行时间关系的图表,并带有指示 O(n²) 或 O(n log n) 拟合的趋势线。

Critically evaluate your experiment: identify limitations (e.g. small sample size, hardware variability), suggest modifications, and discuss how conclusions relate to theoretical concepts. This demonstrates the reflective thinking required for high IA marks.

批判性评估实验:识别局限性(例如小样本量、硬件差异),提出修改建议,并讨论结论如何与理论概念相关联。这展示了获得高 IA 分数所需的反思性思维。

Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading