| 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
"재고 있음"과 같은 yes/no 플래그를 저장하기에 가장 적절한 데이터 타입은 무엇입니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
플래그는 두 가지 상태만 있으므로 BOOLEAN(TRUE/FALSE)이 정확한 선택입니다. "yes"/"no"라는 문자열이 아닙니다.
온도와 같은 측정값을 저장하기에는 실수(floating-point) 타입을 사용해야 합니다.
난이도 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을 생략하고, phoneNumber는 더하거나 곱하지 않습니다. 숫자는 텍스트입니다.
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
레코드는 여러 필드를 하나의 이름 아래에 묶습니다
레코드는 관련 있는 필드들을 묶습니다. 각 필드는 점 표기법(dot notation) — 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 코인 + 오늘 첫 완료 시 소액 보너스
한 레코드 내 서로 다른 타입은 레코드의 핵심 목적입니다. 나머지 세 가지는 시험 관원이放置하는 오류입니다.
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.
레코드의 배열은 하나의 식별자를 사용하여 모든 행이 서로 다른 타입의 필드를 가진 표(table)를 관리할 수 있게 합니다.
난이도 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