Programming Fundamentals: Variables, Data Types and Control Structures | 编程基础:变量、数据类型与控制结构

📚 Programming Fundamentals: Variables, Data Types and Control Structures | 编程基础:变量、数据类型与控制结构

In Edexcel A Level Computer Science, the ‘Programming’ topic focuses on the building blocks needed to design and write reliable programs. This article summarises variables, data types, control structures, subroutines, and recursion, with clear links to pseudocode and the assessment objectives.

在 Edexcel A Level 计算机科学中,“编程”主题聚焦于设计和编写可靠程序所需的基础构件。本文总结变量、数据类型、控制结构、子程序与递归,并结合伪代码与考核目标进行讲解。


1. Variables and Constants | 变量与常量

In programming, a variable is a named location in memory that stores a value. The value can be read, updated, or used in expressions. Most languages require a variable to be declared before use, and some require an explicit data type.

在编程中,变量是内存中命名的存储位置,用于保存数值。该值可以被读取、更新或用于表达式。大多数语言要求变量在使用前声明,有些语言还要求明确指定数据类型。

A constant is a value that remains unchanged throughout the execution of a program. In pseudocode, constants are often declared using the keyword CONST. They help avoid ‘magic numbers’ in code.

常量是在程序执行过程中保持不变的值。在伪代码中,常量通常使用关键字 CONST 声明。它们有助于避免代码中出现“魔法数字”。

  • Variables are mutable; constants are immutable. | 变量可变;常量不可变。
  • Always initialise variables before reading them. | 读取变量前务必先初始化。
  • Use meaningful names such as customerAge rather than x. | 使用有意义的名称,如 customerAge,而不是 x。

2. Primitive Data Types | 原始数据类型

Primitive data types are the basic categories of value that a programming language provides. The most common types are integer, real (floating-point), Boolean, and character.

原始数据类型是编程语言提供的基本值类别。最常见的类型有整型、实数型(浮点型)、布尔型和字符型。

Each type uses a different amount of memory and supports different operations. For example, integers support whole-number arithmetic, while reals support fractional arithmetic.

每种类型占用不同的内存并支持不同的操作。例如,整型支持整数运算,而实数型支持小数运算。

Data type 中文名称 Example values 更多咨询请联系16621398022(同微信)
📞 咨询 / 微信:16621398022(同微信)
A-Level / IGCSE / IB / AP 课程辅导 · 真题资料 · 留学申请规划
查看联系方式 →

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

咨询微信:16621398022(同微信) · 联系我们