📚 IGCSE WJEC Computer Science: Experimental Operation Guide | IGCSE WJEC 计算机:实验操作指南
Practical experimentation lies at the heart of mastering WJEC IGCSE Computer Science. This guide walks you through essential hands-on activities, from writing your first Python program to implementing search algorithms, debugging code, and simulating data representation. Each experiment is designed to build computational thinking skills and prepare you for both coursework and examinations. By following the structured approach, you will deepen your understanding of programming concepts, data structures, and the inner workings of a computer system.
实践操作是掌握WJEC IGCSE计算机科学的核心。本指南将引导你完成关键的动手活动,从编写第一个Python程序,到实现搜索算法、调试代码以及模拟数据表示。每个实验都旨在培养计算思维能力,并为课程作业和考试做好准备。通过这种结构化的学习方式,你将加深对编程概念、数据结构和计算机系统内部工作原理的理解。
1. Setting Up Your Development Environment | 搭建开发环境
Before you start coding, you need a suitable Integrated Development Environment (IDE). For WJEC IGCSE Computer Science, Python 3 is the recommended language. Download and install the latest version from python.org. Choose a simple IDE such as IDLE (comes with Python), Thonny, or Mu. These provide an editor, a shell, and debugging tools. Create a dedicated folder for all your experiments to keep files organised.
在开始编码之前,你需要一个合适的集成开发环境(IDE)。对于WJEC IGCSE计算机科学,推荐使用Python 3。从python.org下载并安装最新版本。选择一个简单的IDE,例如IDLE(随Python提供)、Thonny或Mu。这些IDE提供编辑器、Shell和调试工具。为所有实验创建一个专用文件夹,以便保持文件整洁。
Once the IDE is running, open a new file and save it with a .py extension. Write a simple print("Hello, World!") program to verify that everything works. Run it and observe the output in the console. This confirms your environment is correctly set up.
IDE启动后,打开一个新文件并以.py扩展名保存。编写一个简单的 print("Hello, World!") 程序来验证一切是否正常工作。运行它并观察控制台中的输出。这就确认你的环境已正确搭建。
2. Basic Input and Output Operations | 基本输入输出操作
A fundamental skill is interacting with the user. Use the input() function to prompt for data. Remember that input() always returns a string; you may need to cast it to int() or float() for numerical operations. Experiment by writing a program that asks for a name and age, then displays a greeting message using print() and concatenation or f-strings.
一项基本技能是与用户交互。使用 input() 函数提示输入数据。请记住,input() 始终返回字符串;你可能需要用 int() 或 float() 进行类型转换以进行数值运算。编写一个程序,要求输入姓名和年龄,然后使用 print() 和字符串连接或f-string显示问候消息,从而进行实验。
Output formatting is important. Practice using the print() function with multiple arguments, sep and end parameters. Display a table of values using formatted strings. For instance, print(f"{name} is {age} years old.") provides clear output.
输出格式很重要。练习使用带有多个参数、sep 和 end 参数的 print() 函数。使用格式化字符串显示数值表格。例如,print(f"{name} is {age} years old.") 能提供清晰的输出。
3. Selection and Decision Making | 选择与决策
Conditional statements allow your program to make decisions. The if...elif...else structure is essential. Experiment by creating a grade calculator that takes a percentage score and outputs a letter grade based on given boundaries. Include relational operators (>, <, ==, !=) and logical operators (and, or, not). Test boundary values to see if your conditions work correctly.
条件语句使你的程序能够做出决策。if...elif...else 结构是必不可少的。通过创建一个成绩计算器进行实验,该计算器接收百分比分数并根据给定的界限输出字母等级。包括关系运算符(>、<、==、!=)和逻辑运算符(and、or、not)。测试边界值以检查你的条件是否正确工作。
Use comparison chaining where appropriate, such as 70 <= score <= 100. Write test cases for each branch to validate your logic. This practice builds confidence in handling complex decision trees later.
在适当的地方使用比较链,例如 70 <= score <= 100。为每个分支编写测试用例以验证你的逻辑。这种做法可以增强以后处理复杂决策树的信心。
4. Iteration: Loops and Repetition | 迭代:循环与重复
Loops enable efficient repetition. Experiment with while loops for conditions that depend on user input, and for loops with range() for definite iterations. Write a program that generates a multiplication table. Use nested loops to print patterns such as a square of stars. Observe how the loop counter changes each iteration.
循环可以实现高效的重复。对依赖于用户输入的条件使用 while 循环进行实验,对确定次数的迭代使用带有 range() 的 for 循环。编写一个生成乘法表的程序。使用嵌套循环打印星号正方形等图案。观察循环计数器在每次迭代中的变化。
Be careful with infinite loops—always ensure the loop condition eventually becomes false. Include a break statement to exit early under certain conditions, and continue to skip the rest of the current iteration. Debugging these structures will teach you about flow control.
小心无限循环——始终确保循环条件最终变为假。添加 break 语句以便在特定条件下提前退出,以及使用 continue 跳过当前迭代的剩余部分。调试这些结构将教会你有关流程控制的知识。
5. Data Structures: Lists and Dictionaries | 数据结构:列表与字典
Lists store ordered collections of items. Practice creating lists, accessing elements by index (starting at 0), slicing, and using methods like append(), insert(), remove(), sort(), and reverse(). Create a simple to-do list manager where the user can add, delete, and view tasks. This experiment highlights how data can be dynamically manipulated.
列表存储有序的项集合。练习创建列表、通过索引(从0开始)访问元素、切片,并使用 append()、insert()、remove()、sort() 和 reverse() 等方法。创建一个简单的待办事项列表管理器,用户可以在其中添加、删除和查看任务。该实验突出了如何动态操作数据。
Dictionaries hold key-value pairs, ideal for associating related data. Build a contacts book that maps names to phone numbers. Use keys to retrieve values and the get() method to avoid errors if a key doesn’t exist. Iterate through keys and values with a for loop. Combining lists and dictionaries models real-world data structures.
字典保存键值对,非常适合关联相关数据。构建一个通讯录,将姓名映射到电话号码。使用键检索值,并使用 get() 方法避免键不存在时的错误。使用 for 循环遍历键和值。结合使用列表和字典可以模拟现实世界的数据结构。
6. File Handling: Reading and Writing Data | 文件处理:读写数据
Persistent storage is crucial. Learn to open files in read ('r'), write ('w'), and append ('a') modes. Write a program that records sensor readings (simulated) to a text file, each on a new line. Then read the file back and compute the average. Always close files using the with statement (context manager) to ensure data integrity.
持久化存储至关重要。学习以读取('r')、写入('w')和追加('a')模式打开文件。编写一个程序,将(模拟的)传感器读数记录到文本文件中,每行一个。然后读回文件并计算平均值。始终使用 with 语句(上下文管理器)关闭文件,以确保数据完整性。
Experiment with reading the entire file at once with read(), or line by line using a for loop. Process CSV-style data by splitting strings with the split() method. This mimics handling real data sets in external files, a skill often required in programming projects.
尝试使用 read() 一次性读取整个文件,或使用 for 循环逐行读取。通过使用 split() 方法分割字符串来处理CSV格式的数据。这模拟了处理外部文件中的真实数据集,这是编程项目中经常需要的技能。
7. Debugging Techniques and Error Handling | 调试技巧与错误处理
Errors are part of the learning process. Distinguish between syntax errors (detected by the interpreter), runtime errors (like division by zero or file not found), and logical errors (program runs but gives wrong results). Use print statements strategically to display variable values at key points. Learn to use the IDE’s debugger: set breakpoints, step through code, and inspect variables.
错误是学习过程的一部分。区分语法错误(由解释器检测)、运行时错误(如除零或文件未找到)和逻辑错误(程序运行但结果错误)。策略性地使用 print 语句在关键点显示变量值。学习使用IDE的调试器:设置断点、逐步执行代码和检查变量。
Implement try...except blocks to handle exceptions gracefully. For example, when asking for a number, catch ValueError if the user enters text. This teaches defensive programming and improves the robustness of your experiments.
实现 try...except 块以优雅地处理异常。例如,当要求输入数字时,如果用户输入文本,则捕获 ValueError。这教会你防御性编程,并提高实验的健壮性。
8. Implementing Search Algorithms | 实现搜索算法
Searching is a common computational task. Implement linear search on an unsorted list by iterating through elements until the target is found or the end is reached. Count the number of comparisons. Then implement binary search on a sorted list: repeatedly divide the search interval in half. Use a loop for binary search and compare its efficiency with linear search by using a counter.
搜索是一项常见的计算任务。在未排序的列表上实现线性搜索,通过迭代元素直到找到目标或到达列表末尾。记录比较次数。然后在已排序的列表上实现二分搜索:反复将搜索区间减半。使用循环实现二分搜索,并通过使用计数器将其效率与线性搜索进行比较。
Visualise the search process by printing the indices being examined. For example, in binary search, display the low, mid, and high values at each step. This experiment reveals the power of divide-and-conquer and the importance of data ordering.
通过打印正在检查的索引来可视化搜索过程。例如,在二分搜索中,显示每一步的低位、中位和高位值。这个实验揭示了分治法的威力以及数据排序的重要性。
9. Sorting Algorithms and Performance | 排序算法与性能
Sorting is essential for organising data. Write a bubble sort algorithm that repeatedly steps through a list, compares adjacent elements
Published by TutorHao | IGCSE Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导