📚 Year 9 CCEA Computer Science: Case Study Practical Exercise | Year 9 CCEA 计算机:案例分析实战演练
In this article, we will work through a detailed case study practical exercise designed for the Year 9 CCEA Computer Science curriculum. The aim is to demonstrate how computational thinking skills (decomposition, pattern recognition, abstraction and algorithm design) can be applied to solve a real problem. Our case study involves creating a digital system for a school's extracurricular activity sign-up. By the end, you will understand how to analyse requirements, design an algorithm, write pseudocode, implement a solution in Python, and test it thoroughly.
本文将带领大家完成一个针对 Year 9 CCEA 计算机课程的详细案例分析实战演练。目标是展示如何运用计算思维技能(分解、模式识别、抽象和算法设计)来解决一个真实问题。我们的案例研究涉及为学校课外活动报名创建一个数字系统。通过本演练,你将理解如何分析需求、设计算法、编写伪代码、用 Python 实现解决方案并进行全面测试。
1. Case Study Overview | 案例概述
Our problem: Woodlands Secondary School is organising a sports festival. Students can sign up for one of three sports: Football, Basketball or Badminton. The school needs a simple computer program to record each student's name, class group (e.g., 9A, 9B) and their chosen sport. At the end of registration, the program should display a list of participants for each sport and the total number of sign-ups per sport. There may be multiple students with the same name, so the program must handle this correctly. The system should be text-based and run on a standard computer.
我们的问题:Woodlands 中学正在组织一场体育节。学生可以报名参加以下三个项目之一:足球、篮球或羽毛球。学校需要一个简单的计算机程序来记录每位学生的姓名、班级(例如 9A、9B)和他们选择的运动。在报名结束时,程序应显示每个项目的参与者列表以及每项运动的报名总人数。可能出现同名学生,所以程序必须正确处理这种情况。系统应为基于文本的程序,并在标准计算机上运行。
2. Requirements Analysis | 需求分析
Functional requirements: The program must allow a teacher to repeatedly enter student data until they choose to stop. It must store the data, prevent invalid sport choices, and display the sign-up summary. Non-functional: it should be easy to use and respond quickly. Input: student name (string), class (string), sport (string from a predefined list). Output: three lists showing names under each sport, plus a count for each sport.
功能需求:程序必须允许老师反复输入学生数据,直到选择停止。必须存储数据,防止无效的运动选择,并显示报名汇总。非功能需求:应易于使用且响应迅速。输入:学生姓名(字符串)、班级(字符串)、运动(预定义列表中的字符串)。输出:每个运动项目的参与者姓名列表,以及每个项目的报名计数。
3. Designing Input and Output | 输入与输出设计
We will design the user interface as text prompts. Example dialogue: 'Enter student name (or type STOP to finish): Alice'. Then 'Enter class (e.g., 9A): 9A'. Then 'Choose sport (Football, Basketball, Badminton): Football'. After each entry, a confirmation message: 'Alice from 9A added to Football.' At the end, the output: 'Football (2 sign-ups): Alice, Bob'. 'Basketball (1 sign-up): Charlie'. etc. The sport names must be validated, ignoring case and ensuring correct spelling; we can convert input to title case for consistency.
我们设计基于文本提示的用户界面。对话示例:“请输入学生姓名(或输入 STOP 停止):Alice”。接着“输入班级(如 9A):9A”。然后“选择运动(足球、篮球、羽毛球):足球”。每次录入后显示确认信息:“来自 9A 的 Alice 已加入足球。” 最后输出:“足球(2 人报名):Alice, Bob”,“篮球(1 人报名):Charlie”等。运动名称必须经过验证,忽略大小写并确保拼写正确;我们可以将输入转换为首字母大写以保持一致性。
4. Algorithm Design | 算法设计
Using decomposition, we break the problem into steps: (1) initialise empty lists for each sport, (2) loop: ask for name; if name is 'STOP', break; (3) ask for class; (4) ask for sport and validate; (5) add name and class to the appropriate sport list; (6) display confirmation; (7) repeat; (8) after loop ends, display summary showing each sport's participants and counts. We also need to handle invalid sport input by re-prompting until a valid option is given.
运用分解,我们将问题拆分为步骤:(1)为每项运动初始化空列表;(2)循环:询问姓名;如果姓名为 'STOP',则跳出;(3)询问班级;(4)询问运动并进行验证;(5)将姓名和班级添加到相应运动的列表中;(6)显示确认信息;(7)重复;(8)循环结束后显示汇总,展示每项运动的参与者及人数。我们还需要处理无效的运动输入,通过反复提示直到给出有效选项。
all_list = [], basketball_list = [], badminton_list = []. → Loop: Input name. → If name == 'STOP', go to Summary. → Else Input class. → Input sport. → If sport not in ['Football','Basketball','Badminton' Display success message. → Return to Loop. → Summary: Display each list and count. → End.
我们可以用流程图表示算法:开始 → 初始化 football_list = [], basketball_list = [], badminton_list = []。→ 循环:输入姓名。→ 如果 name == 'STOP',转到汇总。→ 否则输入班级。→ 输入运动。→ 如果运动不在 ['Football','Basketball','Badminton'] 中,则显示错误并重新输入运动。→ 否则将(姓名,班级)添加到相应列表。→ 显示成功消息。→ 返回循环。→ 汇总:显示每个列表及计数。→ 结束。
5. Pseudocode Development | 伪代码开发
structured pseudocode using standard conventions: indentation for loops and conditionals, ← for assignment. Initialise three empty arrays. WHILE True: OUTPUT prompt for name; name ← USER INPUT; IF name = 'STOP' THEN BREAK; ENDIF. OUTPUT prompt for class; class ← USER INPUT. REPEAT: OUTPUT prompt for sport; sport ← USER INPUT; convert sport to title case; IF sport = 'Football' OR 'Basketball' OR 'Badminton' THEN EXIT REPEAT; ELSE OUTPUT 'Invalid sport, please try again.' confirmation. ENDWHILE. THEN summarise each array with count and list of name-class pairs.
我们将使用标准约定编写结构化伪代码:循环和条件使用缩进,← 表示赋值。初始化三个空数组。WHILE True: OUTPUT 询问姓名的提示;name ← USER INPUT;IF name = 'STOP' THEN BREAK;ENDIF。OUTPUT 询问班级的提示;class ← USER INPUT。REPEAT:OUTPUT 询问运动的提示;sport ← USER INPUT;将 sport 转换为首字母大写;IF sport = 'Football' 或 'Basketball' 或 'Badminton' THEN 退出 REPEAT;ELSE OUTPUT '运动无效,请重试。';ENDIF。UNTIL 有效运动。将 (name, class) 添加到该项运动的数组中。OUTPUT 确认信息。ENDWHILE。然后汇总每个数组,显示计数以及姓名-班级对的列表。
6. Data Structures | 数据结构
In Python, we will store each sport's registrations in a list of dictionaries or simply a list of strings (name +
Published by TutorHao | Year 9 Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图