Types and constants · 类型与常量
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Six data types
- The 2026 guide uses
INTEGER,REAL,CHAR,STRING,BOOLEANandDATE. DATEis in this guide. It is not in the IGCSE 0478 syllabus for 2026–2028.- A paper that uses a date tells you the format, because dates are written differently around the world.
中文
六种数据类型
- 2026 指南使用
INTEGER、REAL、CHAR、STRING、BOOLEAN和DATE。 DATE在这份指南里。它不在 IGCSE 0478 的 2026–2028 考纲中。- 用到日期的题目会说明格式,因为世界各地书写日期的方式不同。
DECLARE Name : STRING
DECLARE Done : BOOLEAN
DECLARE Birth : DATE
Name ← "Ada"
Done ← TRUE
OUTPUT Name
OUTPUT Done
English
CONSTANT uses =
- A constant is a name for a value that the program does not change.
- The guide writes
CONSTANT HourlyRate = 6.50— with=, not with the arrow. - Only a literal may stand on the right: a number, or text in quotes.
中文
CONSTANT 使用 =
- 常量是一个名字,代表程序不会改掉的值。
- 指南写成
CONSTANT HourlyRate = 6.50—— 用=,不用箭头。 - 等号右边只能是字面量:一个数字,或引号里的文字。
CONSTANT PassMark = 50
OUTPUT PassMark
English
Watch out
- Variables are stored with
←. Constants are declared with=. - The guide's own date example is written
02/01/2005. On the paper, follow the format the question gives you.
中文
注意
- 变量用
←存值。常量用=声明。 - 指南自己的日期例子写成
02/01/2005。在试卷上,按题目给出的格式书写。
English
Common mistakes
BOOLEANvalues areTRUEandFALSE, in capitals.- A
CHARis one character in single quotes, such as'A'. ASTRINGuses double quotes.
中文
常见错误
BOOLEAN的值是大写的TRUE和FALSE。CHAR是单引号里的一个字符,例如'A'。STRING用双引号。
English
Now you try
- Declare a constant with
=and output it. - Text needs quotes:
"Ada", notAda.
中文
现在你来试
- 用
=声明一个常量并输出它。 - 文字需要引号:
"Ada",不是Ada。
Declare a constant PassMark equal to 50 and output it. Fill in the value on the CONSTANT line. · 声明常量 PassMark,值为 50,并输出它。把值填在 CONSTANT 那一行。
Click Run to see the output here. · 点击“运行”查看此处输出。
Output the word Ada in quotes, so the program prints Ada. · 用引号输出单词 Ada,让程序打印 Ada。
Click Run to see the output here. · 点击“运行”查看此处输出。
Declare Name as a STRING, store Ada, and output it. · 把 Name 声明为 STRING,存入 Ada,并输出它。
Click Run to see the output here. · 点击“运行”查看此处输出。