Case Study Practical Exercises | 案例分析实战演练

📚 Case Study Practical Exercises | 案例分析实战演练

Welcome to this hands-on case study session designed for Year 7 CCEA Computer Science. Throughout this article, we will explore real-world scenarios that help you understand core computing concepts such as algorithms, data representation, programming, and digital safety. Each case study presents a problem, guides you through a step-by-step solution, and reinforces your learning with practical tasks. By the end, you will see how computer science applies to everyday situations and build your confidence in tackling exam-style questions.

欢迎来到为Year 7 CCEA计算机科学设计的动手案例分析课程。本文将通过真实场景帮助你理解算法、数据表示、编程和数字安全等核心计算概念。每个案例都会呈现一个问题,引导你一步步解决,并通过实际任务巩固学习。最终,你将看到计算机科学如何应用于日常生活,并增强处理考试风格问题的信心。

1. Case Study: Designing a Simple Quiz Game | 案例研究:设计一个简单问答游戏

Imagine you have been asked to create a quiz game for your classmates. The game should ask five questions, check the answers, and give a final score. Before coding, you need to plan the algorithm using pseudocode and a flowchart.

假设要求你为同学设计一个问答游戏。游戏应提出五个问题,检查答案并给出最终得分。在编程前,你需要用伪代码和流程图规划算法。

Start by listing the steps in plain English: display a welcome message, set score to zero, ask question 1, get user input, compare input with correct answer, if correct add one to score, repeat for all questions, and finally display the total score. This logical sequence is the algorithm.

首先用简单英语列出步骤:显示欢迎信息,设置分数为零,提问第一题,获取用户输入,将输入与正确答案比较,如果正确则分数加一,对所有题目重复,最后显示总分。这一逻辑顺序就是算法。

Step Pseudocode
1 OUTPUT “Welcome to the Quiz!”
2 score ← 0
3 OUTPUT “What is the capital of France?”
INPUT user_answer
IF user_answer = “Paris” THEN
   score ← score + 1
ENDIF
4 … [repeat for remaining questions]
5 OUTPUT “Your score is: “, score

The flowchart for this quiz would use ovals for start/end, rectangles for processes, parallelograms for input/output, and diamonds for decisions. Sequencing, selection (IF-THEN), and iteration (if you allowed replaying) are all demonstrated here.

这个问答游戏的流程图将用椭圆形表示开始/结束,矩形表示处理,平行四边形表示输入/输出,菱形表示判断。这里展示了顺序、选择(IF-THEN)和迭代(如果允许重玩)。


2. Handling User Input and Validation | 处理用户输入与验证

In the quiz case, what happens if a user enters “PARIS” or “paris” instead of “Paris”? String comparison is case-sensitive in most programming languages. We must plan for input validation to make the game fair.

在问答案例中,如果用户输入 “PARIS” 或 “paris” 而不是 “Paris” 会发生什么?在大多数编程语言中,字符串比较区分大小写。我们必须规划输入验证以确保游戏公平。

One solution is to convert both the user input and the correct answer to the same case using a function like UPPER() or lower(). Pseudocode: IF UPPER(user_answer) = UPPER(“Paris”) THEN … This ensures “paris” and “PARIS” are accepted. Another validation check ensures input is not empty.

一种解决方案是使用诸如 UPPER() 或 lower() 的函数将用户输入和正确答案转换为相同的大小写。伪代码:IF UPPER(user_answer) = UPPER(“Paris”) THEN … 这样可以接受 “paris” 和 “PARIS”。另一种验证确保输入不为空。

Additionally, for numeric inputs like “how many continents are there?”, we should check that the input is a number before comparing. Flowcharts can include extra decision boxes to handle invalid entries and ask the user to try again.

此外,对于像“地球有几大洲?”这样的数字输入,我们应在比较前检查输入是否为数字。流程图可以包含额外的判断框来处理无效输入并要求用户重试。


3. Storing and Managing Data for the Questions | 存储和管理题目数据

Rather than hard-coding five questions one by one, a better approach is to store the questions and answers in a data structure like a list or array. This makes the code reusable and easier to update.

与其一个接一个地硬编码五个问题,更好的方法是将问题和答案存储在列表或数组等数据结构中。这样代码可重用且更易更新。

For example, we could create two parallel lists: questions = [“Capital of France?”, “5 + 3?”, …] and answers = [“Paris”, “8”, …]. A loop can then index through both lists using a counter variable i from 0 to 4. Inside the loop, ask question[i], get input, compare with answer[i].

例如,我们可以创建两个平行列表:questions = [“Capital of France?”, “5 + 3?”, …] 和 answers = [“Paris”, “8”, …]。然后循环可以用计数器变量 i 从 0 到 4 遍历这两个列表。循环内,提问 question[i],获取输入,与 answer[i] 比较。

This demonstrates the concept of data abstraction and how computing systems organize information. Even in Year 7, understanding that programs can pull data from external sources (like a text file) is valuable.

这展示了数据抽象的概念以及计算系统如何组织信息。即使在 Year 7,理解程序可以从外部来源(如文本文件)提取数据也是很有价值的。


4. Introduction to Binary Representation in a Game Score | 游戏分数中的二进制表示入门

Your quiz game displays a score out of 5. But how would a computer represent that score internally? Computers use binary – only 0s and 1s. The number 5 is stored as 0101 in a 4-bit system. Understanding binary helps you see how data is encoded.

你的问答游戏显示一个满分为 5 的分数。但计算机内部如何表示这个分数?计算机使用二进制——只有 0 和 1。在 4 位系统中,数字 5 存储为 0101。理解二进制有助于理解数据编码方式。

Let’s convert the number of correct answers (e.g., 3) into binary. Use the place values 8,4,2,1. Since 3 = 2+1, we place 0 in the 8s and 4s columns, 1 in the 2s column, and 1 in the 1s column, giving 0011. A table helps visualize:

我们将正确答案数(例如 3)转换为二进制。使用位值 8、4、2、1。因为 3 = 2+1,我们在 8 和 4 列放 0,在 2 列放 1,在 1 列放 1,得到 0011。一个表格有助于可视化:

8s 4s 2s 1s
0 0 1 1

Binary isn’t just for numbers; it represents instructions, text, and colours. Every character you type is encoded with ASCII or Unicode binary codes. When the quiz stores a player’s name, that name is a sequence of binary values.

二进制不仅用于数字;它表示指令、文本和颜色。你输入的每个字符都用 ASCII 或 Unicode 二进制编码。当问答游戏存储玩家姓名时,该姓名就是一系列二进制值。


5. Case Study: A Digital Stopwatch and the Role of Input/Output | 案例研究:数字秒表与输入/输出的作用

Consider a simple digital stopwatch app. The user can press start, stop, and reset. Behind the scenes, there is a processor running a timing loop and updating the display. This case study illustrates input, process, output (IPO) model.

考虑一个简单的数字秒表应用。用户可以按下开始、停止和重置。背后有一个处理器运行计时循环并更新显示。本案例说明了输入、处理、输出(IPO)模型。

Input comes from the buttons. When the user presses ‘start’, the system records the current system time (input). The process involves repeatedly checking the elapsed time by subtracting the start time from the current time, converting milliseconds into minutes, seconds, and hundredths. Output is the changing numbers on the screen.

输入来自按钮。当用户按下“开始”时,系统记录当前系统时间(输入)。处理涉及不断检查经过的时间,通过从当前时间减去开始时间,将毫秒转换为分钟、秒和百分之一秒。输出是屏幕上变化的数字。

Designing this on paper requires a flowchart showing a loop that continues until ‘stop’ is pressed. Inside the loop, the program calculates elapsed time and updates the display. This introduces the concept of continuous loops and event handling – key ideas in interactive systems.

在纸上设计需要流程图显示一个循环,直到按下“停止”为止。循环内部,程序计算经过时间并更新显示。这引入了连续循环和事件处理的概念——交互式系统的关键思想。


6. Cybersecurity Challenge: Recognising Phishing Emails | 网络安全挑战:识别钓鱼邮件

Your school has launched a campaign to raise cybersecurity awareness. As part of a case study, you must analyse an email and decide if it is genuine or a phishing attempt. Look at the sender address, spelling errors, urgent requests, and suspicious links.

你的学校发起了一项提升网络安全意识的活动。作为案例研究的一部分,你必须分析一封邮件,判断它是真实的还是钓鱼尝试。查看发件人地址、拼写错误、紧急请求和可疑链接。

A typical phishing email might claim “Your account will be locked!” and ask you to click a link to verify your password. The link might look like http://www.bank-secure.com but actually leads to a fake site. Hovering over the link reveals the true URL. Never share personal details via email.

典型的钓鱼邮件可能声称“您的帐户将被锁定!”并要求点击链接验证密码。链接可能看起来像 http://www.bank-secure.com,但实际指向一个虚假网站。将鼠标悬停在链接上可显示真正的 URL。切勿通过邮件分享个人资料。

To protect yourself, always check the sender’s email address. Official organisations do not ask for passwords via email. Additionally, manually type the website address instead of clicking links. Report suspicious emails to your teacher or IT support.

为了保护自己,请始终检查发件人的电邮地址。官方机构不会通过邮件索要密码。此外,手动输入网址而不是点击链接。向老师或 IT 支持报告可疑邮件。


7. Understanding Sequencing, Selection, and Iteration through a Vending Machine | 通过自动售货机理解顺序、选择和迭代

A vending machine is a perfect example of computing concepts in everyday life. The machine executes a fixed sequence: wait for coin insertion, show current credit, allow item selection, check if enough money, dispense item, and return change. This is sequencing.

自动售货机是日常生活中计算概念的完美例子。机器执行固定顺序:等待投币,显示当前金额,允许选择商品,检查金额是否足够,出货,找零。这就是顺序。

Selection occurs when the system checks the coin value and the item price. If credit ≥ price, the item is dispensed; ELSE, display “insufficient funds”. This is an IF-THEN-ELSE structure. For multiple items, a CASE or nested IF can be used.

选择发生在系统检查币值和商品价格时。如果金额 ≥ 价格,则出货;否则显示“金额不足”。这是一个 IF-THEN-ELSE 结构。对于多个商品,可以使用 CASE 或嵌套 IF。

Iteration is seen when the machine stays in a loop, continuously accepting coins until the user presses a cancel button or selects an item. This loop can be drawn as a repeat-until flowchart. Thus, a simple machine embodies the three programming pillars.

迭代体现在机器循环运行,持续接受硬币,直到用户按下取消按钮或选择商品。这个循环可以画成重复-直到流程图。因此,一台简单的机器体现了编程的三大支柱。


8. Data Representation in Images: Pixel Art Case | 图像中的数据表示:像素艺术案例

Computers represent images using a grid of pixels. In Year 7, you may have learned about bitmap images. Each pixel has a binary colour value. For a black-and-white image, 0 could mean white and 1 black. Let’s decode a simple 4×4 smiley face.

计算机用像素网格表示图像。在 Year 7,你可能学习过位图图像。每个像素有二进制颜色值。对于黑白图像,0 可表示白色,1 表示黑色。我们来解码一个简单的 4×4 笑脸。

Grid:

Row 1: 0 1 1 0

Row 2: 1 0 0 1

Row 3: 1 0 0 1

Row 4: 0 1 1 0

Here, the 1s form a mouth and eyes. If we assign one byte per pixel, this tiny image uses 16 bytes. Adding more colours increases file size because each colour needs more bits (e.g., 8 bits for 256 colours).

网格:

第1行:0 1 1 0

第2行:1 0 0 1

第3行:1 0 0 1

第4行:0 1 1 0

这里,1 形成嘴巴和眼睛。如果每像素一个字节,这张小图使用 16 字节。增加更多颜色会增大文件大小,因为每种颜色需要更多位(例如,256 色需要 8 位)。

This case demonstrates metadata: the image file also stores dimensions (4×4), colour depth, and file format. When you take a photo, the camera saves that data alongside the pixels, so software knows how to display it.

这个案例展示了元数据:图像文件还存储尺寸(4×4)、颜色深度和文件格式。当你拍照时,相机会将这些数据与像素一起保存,以便软件知道如何显示。


9. Algorithm Efficiency: Searching for a Name in a List | 算法效率:在列表中搜索姓名

Suppose you have a list of 100 student names stored alphabetically. You need to find “Sophie”. A linear search would check each name from the start until found – worst-case 100 checks. But because the list is sorted, you can use binary search, which is much faster.

假设你有一个按字母顺序存储的 100 名学生名单。你需要找到“Sophie”。线性搜索将从头开始检查每个名字直到找到——最坏情况 100 次检查。但由于列表已排序,你可以使用二分搜索,速度快得多。

Binary search works by repeatedly dividing the search interval in half. Compare the target with the middle name. If the middle name comes before “Sophie”, discard the first half; otherwise discard the second half. With each step, the search space halves. For 100 names, a maximum of 7 comparisons are needed because 2⁷ > 100.

二分搜索通过反复将搜索区间分成两半来工作。比较目标与中间的名字。如果中间名字在“Sophie”之前,舍弃前半部分;否则舍弃后半部分。每步搜索空间减半。对于 100 个名字,最多需要 7 次比较,因为 2⁷ > 100。

This case study shows why choosing the right algorithm matters. In computing, efficiency affects how quickly a program runs. Even Year 7 students can appreciate that a smartphone searching contacts uses binary search, not linear, to appear instant.

这个案例研究表明选择正确的算法为何重要。在计算中,效率影响程序运行速度。即使是 Year 7 学生也能理解,智能手机搜索联系人使用二分搜索而非线性搜索,因此瞬间完成。


10. Developing a Scratch Program to Simulate a Traffic Light | 开发模拟交通灯的 Scratch 程序

Using a block-based language like Scratch, you can model a traffic light system. The task: create sprites for red, yellow, and green lights that change in a timed sequence. This reinforces sequencing and loops, but also introduces timing and states.

使用像 Scratch 这样的基于块的语言,你可以模拟交通灯系统。任务:创建红、黄、绿灯的精灵,按定时顺序变化。这巩固了顺序和循环,还引入了计时和状态。

The algorithm: when green flag clicked, forever: broadcast “red”, wait 5 seconds; broadcast “red+yellow”, wait 2 seconds; broadcast “green”, wait 5 seconds; broadcast “yellow”, wait 2 seconds. Each light sprite listens for the broadcast and shows/hides accordingly.

算法:当点击绿旗时,永远循环:广播“红”,等待 5 秒;广播“红+黄”,等待 2 秒;广播“绿”,等待 5 秒;广播“黄”,等待 2 秒。每个灯的精灵接收广播并相应显示/隐藏。

Testing and debugging are essential. If the lights overlap or timing is wrong, you adjust the wait blocks. This case teaches decomposition: breaking a problem into smaller parts (sprites, broadcasts, timing) and solving them step by step.

测试和调试至关重要。如果灯光重叠或时间错误,你调整等待块。这个案例教授分解:将问题分解为更小的部分(精灵、广播、计时)并一步步解决。


11. Digital Footprint and Online Reputation | 数字足迹与网络声誉

Every time you post a comment, share a photo, or play an online game, you leave a digital footprint. Imagine a future employer searching your name – what will they find? This case study helps you reflect on your online behaviour.

每次你发表评论、分享照片或玩在线游戏,都会留下数字足迹。想象一下未来雇主搜索你的名字——他们会发现什么?这个案例研究帮助你反思在线行为。

Consider a scenario: Sasha posted a funny but unkind meme about a teacher two years ago. Now applying for a scholarship, the reviewing panel finds that post. The reputation damage may affect her chances. Think before you post: is it true, helpful, inspiring, necessary, kind (THINK)?

考虑一个场景:萨莎两年前发布了一个搞笑但不友善的关于老师的表情包。现在申请奖学金,评审小组发现了这个帖子。声誉损害可能影响她的机会。发布前请思考:真实、有益、激励、必要、友善(THINK)?

Privacy settings are crucial but not foolproof. Even deleted posts can be screenshotted. Older students should also be aware of data collection by apps – location, browsing history – and how that creates a permanent record.

隐私设置至关重要但并非万无一失。即使是已删除的帖子也可能被截图。高年级学生还应了解应用程序对数据的收集——位置、浏览历史——以及它们如何创建永久记录。


12. Putting It All Together: Exam-style Integrated Task | 综合应用:考试风格的综合任务

Let’s design a mini-project that ties together many Year 7 topics. Task: “Create a presentation or written report that analyses a computerised till (POS) system in a supermarket. Describe the hardware, software, user interface, data handling, and security concerns.”

让我们设计一个将许多 Year 7 主题联系在一起的小型项目。任务:“制作演示文稿或书面报告,分析超市的电脑收银(POS)系统。描述硬件、软件、用户界面、数据处理和安全问题。”

Address each area: Hardware includes barcode scanner, receipt printer, touchscreen, and cash drawer. Software processes the scanned items, calculates total, applies discounts, and sends commands to hardware. User interface must be intuitive, with large buttons for common items and clear feedback.

探讨每个方面:硬件包括条形码扫描器、收据打印机、触摸屏和钱箱。软件处理扫描的商品,计算总额,应用折扣,并向硬件发送命令。用户界面必须直观,常用商品有大按钮和清晰反馈。

Data handling involves retrieving product details (name, price) from a database using the barcode as a primary key. When the sale is complete, stock levels are updated. Security includes authentication for staff logins and encryption of customer payment data. This holistic view mirrors how professional analysts work.

数据处理涉及使用条形码作为主键从数据库检索产品详细信息(名称、价格)。销售完成时,库存水平会更新。安全包括员工登录的身份验证和客户支付数据的加密。这种整体视角反映了专业分析师的工作方式。

Published by TutorHao | CCEA Year 7 Computing 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