| English | 意味 |
|---|---|
| data type/ˈdeɪtə taɪp/ | データ型 |
| field/fiːld/ | フィールド |
| record/ˈrekɔːd/ | レコード |
| record structure/ˈrekɔːd ˈstrʌktʃə/ | レコード構造 |
| dot notation/dɒt nəʊˈteɪʃn/ | ドット表記 |
The most expensive data-type decision in history
- In the 1960s memory cost more than programmers. To save two characters per date, years were stored as two digits:
99meant 1999. - Nobody expected the code to outlive the century. It did, and on 1 January 2000 every one of those fields would read as 1900. Governments and companies spent an estimated $300 billion checking and fixing it.
- The bug was not a typo. It was a data type 数据类型 chosen for the memory of 1965 and kept for the dates of 2000.
- This lesson is how to pick the type that fits the data, and how to bundle values that belong together into a record 记录.
The six basic types
| Type | Holds | Use it for |
|---|---|---|
INTEGER |
a whole number, 42, -7 |
counts, indexes, IDs |
REAL |
a number with a fractional part, 3.14 |
measurements, averages |
CHAR |
a single character, 'A' |
a grade letter, a menu choice |
STRING |
characters in quotes, "Hello" |
text |
BOOLEAN |
TRUE or FALSE |
flags |
DATE |
a calendar date | dates of birth, deadlines |

Pseudocode also names two structured types: ARRAY and FILE
"在庫あり"のようなはい/いいえフラグを格納するのに最適なデータ型はどれですか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
フラグには2つの状態があるため、文字列"yes"/"no"ではなく、BOOLEAN (TRUE/FALSE)が正確な選択肢です。
温度のような測定値を格納するには、実数(浮動小数点型)を使用すべきです。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
整数は個数やカウントに使用され、実数は測定値に使用されます。
Choose by how the value is used
- A type is decided by what the program will do with the value, not by how it looks.
- The number of students is
INTEGER; the class's average mark isREAL, because it has a fractional part; whether a student has paid isBOOLEAN. - An array index is always
INTEGER. A single grade letter isCHAR; an email address isSTRING. - A phone number is a
STRING: it starts with0, and nobody ever adds two phone numbers.
各値に最適なデータ型を対応させてください。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
正確なタイプを選択してください:フラグにはBOOLEAN、分数値にはREAL、整数のカウントにはINTEGER、テキストにはSTRINGを使用します。
電話番号(例: 07700 900123)を格納するのに適切なデータ型はどれですか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
INTEGERだと先頭の0が消えてしまい、電話番号を足したり掛けたりするプログラムはありません。桁はテキストとして扱われます。
Worked example: give the appropriate data type
| Data | Type | Because |
|---|---|---|
| number of items in stock | INTEGER |
a whole count |
| price of an item | REAL |
has pence, a fractional part |
| whether the item is on offer | BOOLEAN |
only two states |
the item's category code, 'F' |
CHAR |
exactly one character |
| the supplier's name | STRING |
text |
| the date the item was delivered | DATE |
a calendar date |
- Give the pseudocode name, not the language you happen to know:
BOOLEAN, notbool;REAL, notfloat.
配列のインデックスのデータ型は常に ____ です。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
インデックスは位置を数えるため、整数です。Names[2.5]という表現には意味がありません。
Records
- A record (a record structure 记录结构) holds a set of data items of different data types under one identifier. Each item is a field 字段.
- Use one when several values always describe one thing: a stock item, a customer, a student.
TYPE TStockItem
DECLARE ItemID : INTEGER
DECLARE Category : STRING
DECLARE ItemCost : REAL
DECLARE InStock : BOOLEAN
ENDTYPE

One identifier, four fields, four types
レコードは次のために使用されます:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
レコードは一つのものを説明する(異なる可能性のある)タイプのフィールドを束ねます。配列は同じ型の多数の値を保持します。
Declaring and using a record
TYPE … ENDTYPEdefines the type. Then declare variables of it, singly or as an array:
DECLARE Item1 : TStockItem
DECLARE Items : ARRAY[1:100] OF TStockItem
- Reach a field with dot notation 点号表示法, to write and to read:
Item1.Category ← "Fruit"
OUTPUT Item1.Category, " costs ", Item1.ItemCost
Items[7].InStock ← FALSE
レコードは複数のフィールドを一つの名称の下にまとめます
レコードは関連するフィールドを束ねます。各フィールドは名前付きラベルであり、数値インデックスではなく、ドット表記(Item1.Category)でアクセスします。
レコード変数Item1のCategoryフィールドを設定する場合、以下のように書きます:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
ドット表記 record.fieldは、レコードのフィールドにアクセスするために使用されます。
Worked example: the club membership file
- A club stores, for each student, a student ID (a string), a name, a date of birth and up to three club numbers. Declare the record type, an array for 3000 students, and store a name in the first element.
TYPE Student
DECLARE StudentID : STRING
DECLARE Name : STRING
DECLARE DateOfBirth : DATE
DECLARE Club : ARRAY[1:3] OF INTEGER
ENDTYPE
DECLARE Membership : ARRAY[1:3000] OF Student
Membership[1].Name ← "Li Wei"
- The marks:
TYPEwith the identifier andENDTYPE; every field declared with a suitable type; the array with its bounds andOF Student; the field reached with the index and the dot.
クラブ会員宣言の各行を正しい順序に並べ替えてください。
難易度 3/5 · 200 コイン + 今日初回完了時に小ボーナス付与
タイプを定義して閉じ、その変数または配列を宣言し、最後にインデックスとドットを使ってフィールドにアクセスします。
Worked example: state the error in the declaration
TYPE TBooking
DECLARE Seats : INTEGER
DECLARE Price
DECLARE Total : STRING
- Three errors, each a mark: the type has no
ENDTYPE; the fieldPricehas no data type; andTotalwill holdSeats * Price, an arithmetic result, so it cannot be aSTRING. - The examiner's usual three: a missing
ENDTYPE, a field without a type, a field of the wrong type for what is done with it.
レコード宣言における誤りはどれですか?すべて選択してください。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
一つのレコード内で異なる型を使うことがレコードの本質です。残りの3つが出題者が仕込む誤りです。
Record, array, or plain variables
- Values that always belong together and have different types: a record.
- Many values of the same type under one name: an array (next lesson).
- A table of rows where each row has mixed fields: an array of records,
Members[i].Name. - Unrelated values: separate variables. Bundling them gains nothing.
レコードの配列は、一つの識別子で、各行に異なるタイプのフィールドを持つテーブルを保持することを可能にします。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
Members[i]は一行(レコード)であり、Members[i].Nameは一つのセルです。配列が行を提供し、レコードが混合された列を提供します。
Marks that slip away
- A yes/no value is a
BOOLEAN, not the strings"yes"and"no". - A phone number or an ID that starts with
0is aSTRING, never anINTEGER. - Money in a
REALpicks up rounding errors; many systems store whole pennies as anINTEGER. - Every field is a
DECLAREline with a type, and the type ends withENDTYPE. The index goes on the array, the dot on the field:Members[3].Name.
You've got it
- six basic types,
INTEGER,REAL,CHAR,STRING,BOOLEAN,DATE, chosen by what the program does with the value - a record holds fields of different types under one identifier:
TYPE … DECLARE field : type … ENDTYPE - declare variables or arrays of the type, and reach a field with dot notation:
Membership[1].Name ← "Li Wei" - the errors the examiner plants: no
ENDTYPE, a field with no type, a field typed wrongly for its use