Program Function and Purpose
導入済み
6:10
創造的開発
Here is a program that should print the average of two numbers. It runs. It does not crash. It prints an answer — and the answer is wrong. Give it four and six…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| purpose/ˈpɜːpəs/ | 目的 |
| function/ˈfʌŋkʃn/ | 機能 |
| behavior/bɪˈheɪvjə/ | 振る舞い |
| Input/ˈɪnpʊt/ | 入力 |
| Processing/ˈprəʊsesɪŋ/ | 処理 |
| Output/ˈaʊtpʊt/ | 出力 |
| events/ɪˈvents/ | イベント |
| event-driven/ɪˈvent ˈdrɪvən/ | イベント駆動 |
| event handler/ɪˈvent ˈhændlə/ | イベントハンドラ |
目的と機能
- コードを書く前に、関連する二つの概念について明確にしておく必要があります。
- プログラムの目的とは、それが存在する理由 — 解決すべき問題です。
- 機能とは、それが做什么するものか — ユーザーが見る振る舞いです。
- 天気アプリの目的は「人を助けて計画を立てる」;その機能は「予報を表示する」です。
Input, processing, or output?
Every program takes input, processes it by its instructions, and produces output. Sort each part of a program into the right stage.
A program's purpose is why it exists; its function is:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Purpose = the goal; function = the visible behavior that reaches it.
Which is an example of input?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A tap is data the program receives; the others are outputs.
入力 → 処理 → 出力モデル
- すべてのプログラムは単純なモデルに従います: 入力 → 処理 → 出力 (IPOモデル)。
- 入力: プログラムが受け取るデータ — キーボード入力、センサー、ファイル、インターネット。
- 処理: その入力に対して行う一連の手順。
- 出力: 結果 — テキスト、音、保存されたファイル、ロボットが動くこと。

すべてのプログラムは入力、処理、出力に分解される

Put the IPO model in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Data comes in, is processed, and a result goes out.
A program that waits and reacts to clicks and key presses is ______-driven.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Each event triggers an event handler.
A program always gives the same output, whatever input it receives.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
False. A program's behavior is how it responds to input, so different inputs can give different outputs.
振る舞いとイベント
- プログラムの振る舞いとは、入力が与えられた時どのように反応するか — 異なる入力が異なる出力をもたらすことがあります。
- 多くの現代のプログラムはイベント駆動型: クリックやキー押しのようなイベントを待機し、反応します。
- 各イベントはイベントハンドラーと呼ばれる小さなコードブロックをトリガーします。
- ゲーム、ウェブサイトボタン、チャットアプリはすべてイベント駆動型です。
A well-designed program should: (Select all that apply)
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Good design also handles every possible input, including unusual ones.
良く設計されたプログラムがすること
- ユーザーのために本格的な問題を解決します。
- 期待される入力と提供される出力について明確です。
- 毎回実行するごとに、その仕事を確実に遂行します。
- ありとあらゆる可能な入力を考えることは、正しく設計することの一部です。
このカードは新しいため、翻訳ができるまで英語で表示されます。
Worked example: a step-counter app
A step-counter app helps people stay active. It reads the phone's motion sensor, counts each step, and shows the day's total; when the user taps "Reset", the count goes back to zero. Identify its purpose, function, input, processing, output and an event.
- Purpose: help people stay active. Function: count and display steps. Input: motion sensor data and taps on the screen.
- Processing: detect a step pattern in the sensor data and add 1 to the count. Output: the step total on screen. Event: tapping "Reset" triggers its event handler 事件处理程序, which sets the count to 0.
In a calculator app, the user typing "7 × 6" is the:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
It is data given to the program.
In an event-driven program, code runs in response to actions such as a click or key press.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Each event triggers its handler.
プログラムの目的とはそれが存在する理由;機能とはそれが做什么するものかです。すべてのプログラムは入力 → 処理 → 出力 (IPOモデル) に当てはまります。その振る舞いとは入力が与えられた時の反応 — 多くのプログラムはイベント駆動型で、イベントハンドラーを通じてクリックやキー押しに反応します。
何が問題でしたか?この内容はサイトの運営チームだけが確認します。