文章目录
程序员常用单词汇总
一、数据类型相关单词
- Integer(int)
- 记忆方法:“Integer”读音与“整”相似,很容易联想到整数。它在程序中用于表示没有小数部分的数字。
- 例句:“Declare an integer variable
num
to store the number of students.”(声明一个整数变量“num”来存储学生的数量。)
- Float
- 记忆方法:读音类似“漂浮”,在数据类型中,它表示带有小数部分的浮点数,就像数字在小数点后“漂浮”。
- 例句:“The result of the division is a float value, which may have decimal places.”(除法运算的结果是一个浮点值,可能有小数位。)
- Double
- 记忆方法:“double”本身有“两倍”的意思,在数据类型中,它比“float”能表示更精确的浮点数,精度大概是“float”的两倍。
- 例句:“When dealing with very precise scientific calculations, a double - precision variable is often used.”(在进行非常精确的科学计算时,经常使用双精度变量。)
- Character(char)
- 记忆方法:和“character”在日常英语中的意思“字符”相关,用于存储单个字符,如字母、数字或符号。
- 例句:“A character variable
c
is used to store a single letter from the alphabet.”(一个字符变量“c”用于存储字母表中的单个字母。)
- String
- 记忆方法:“string”有“一串、一行”的意思,在编程中用于存储字符序列,就像一串珠子(字符)串在一起。
- 例句:“The user’s name is stored as a string in the database.”(用户的名字作为字符串存储在数据库中。)
- Boolean(bool)
- 记忆方法:以英国数学家乔治·布尔(George Boole)命名,只有“true”(真)和“false”(假)两个值,用于逻辑判断。
- 例句:“The boolean variable
isValid
checks whether the input meets the requirements.”(布尔变量“isValid”检查输入是否符合要求。)
二、编程结构相关单词
- If
- 记忆方法:日常英语中“if”表示“如果”,在编程中用于条件判断。
- 例句:“If the temperature is above 30 degrees, turn on the air - conditioner.”(如果温度高于30度,就打开空调。)
- Else
- 记忆方法:常和“if”一起使用,意思是“否则”,在条件不满足“if”的情况下执行。
- 例句:“If you pass the exam, you will get a reward; else, you need to study harder.”(如果你通过了考试,你会得到奖励;否则,你需要更努力地学习。)
- Else - if
- 记忆方法:是“if - else”结构的扩展,用于多个条件的判断。
- 例句:“If the score is 90 - 100, grade is ‘A’; else - if the score is 80 - 89, grade is ‘B’; else grade is ‘C’.”(如果分数在90 - 100之间,等级是’A’;否则如果分数在80 - 89之间,等级是’B’;否则等级是’C’。)
- Switch
- 记忆方法:有“转换、切换”的意思,在编程中用于多分支选择结构。
- 例句:“The switch statement is used to select one of many code blocks to be executed based on the value of an expression.”(“switch”语句用于根据表达式的值选择要执行的多个代码块之一。)
- Case
- 记忆方法:在“switch”结构中,“case”表示“情况”,每个“case”后面跟着一个值和对应的执行语句。
- 例句:“In a switch statement, each case represents a possible value of the variable being tested.”(在“switch”语句中,每个“case”代表被测试变量的一个可能值。)
- Default
- 记忆方法:在“switch”结构中,“default”表示“默认”,当其他“case”都不匹配时执行。
- 例句:“The default case in a switch statement is executed when none of the other cases match the value.”(当“switch”语句中的其他“case”都不匹配该值时,执行默认情况。)
- For
- 记忆方法:日常英语中有“为了、对于”的意思,在编程中用于循环,指定循环的开始条件、结束条件和迭代方式。
- 例句:“For (int i = 0; i < 10; i++) { // loop body }”(对于(整数i = 0;i < 10;i++){ // 循环体})
- While
- 记忆方法:有“当……的时候”的意思,只要条件为真,就会执行循环体中的代码。
- 例句:“While (the battery level > 0) { // keep the device running }”(当(电池电量> 0)时{ // 保持设备运行})
- Do - while
- 记忆方法:是“while”循环的变体,先执行一次循环体,再判断条件。
- 例句:“Do { // at least execute the code once } while (the user wants to continue);”(做{ // 至少执行一次代码}当(用户想要继续)时;)
三、函数和方法相关单词
- Function
- 记忆方法:在数学和编程中都有“函数”的意思,是一段可重复使用的代码块,接受输入并返回输出。
- 例句:“A function
add
is defined to add two numbers and return the result.”(定义了一个函数“add”来将两个数字相加并返回结果。)
- Method
- 记忆方法:在面向对象编程中,“method”是对象的行为,和“function”类似,但与对象紧密相关。
- 例句:“The
draw
method of theShape
class is used to display the shape on the screen.”(“Shape”类的“draw”方法用于在屏幕上显示形状。)
- Parameter(arg)
- 记忆方法:读音类似“帕拉米特”,可以联想成“旁边的度量”,在函数或方法中用于接收外部传入的值。
- 例句:“The function
calculateArea
takes two parameters, length and width, to calculate the area of a rectangle.”(函数“calculateArea”接受两个参数,长度和宽度,用于计算矩形的面积。)
- Return
- 记忆方法:有“返回”的意思,用于从函数或方法中返回一个值。
- 例句:“The function
getMax
returns the larger of the two input numbers.”(函数“getMax”返回两个输入数字中较大的一个。)
四、变量和常量相关单词
- Variable
- 记忆方法:“variable”本身有“可变的”意思,在编程中,变量的值可以在程序运行过程中改变。
- 例句:“The variable
count
is used to keep track of the number of times an event occurs.”(变量“count”用于跟踪一个事件发生的次数。)
- Constant
- 记忆方法:有“不变的、常量”的意思,在程序运行期间其值不能被修改。
- 例句:“The constant
PI
is defined as 3.14159 and is used in various mathematical calculations.”(常量“PI”被定义为3.14159,用于各种数学计算。)
- Global
- 记忆方法:有“全球的、全局的”意思,在编程中,全局变量可以在整个程序的多个部分访问。
- 例句:“A global variable
totalScore
is accessible from different functions in the program.”(一个全局变量“totalScore”可以从程序中的不同函数访问。)
- Local
- 记忆方法:有“局部的”意思,局部变量只能在定义它的代码块(如函数内部)中使用。
- 例句:“The local variable
temp
inside the function is only valid within that function.”(函数内部的局部变量“temp”只在该函数内有效。)
五、面向对象编程相关单词
- Class
- 记忆方法:在学校里“class”是班级,在编程中有“类”的意思,是对象的模板,定义了对象的属性和方法。
- 例句:“The
Car
class defines the properties such as color, speed and methods like drive and stop.”(“Car”类定义了诸如颜色、速度等属性和像驾驶、停止这样的方法。)
- Object
- 记忆方法:日常英语中有“物体、对象”的意思,在编程中是类的实例,具有类定义的属性和方法。
- 例句:“An object of the
Student
class represents an individual student with his/her own name and grade.”(“Student”类的一个对象代表一个有自己名字和年级的学生个体。)
- Inheritance
- 记忆方法:有“继承”的意思,在面向对象编程中,子类可以继承父类的属性和方法。
- 例句:“The
SubClass
inherits the properties and methods of theSuperClass
and can also have its own unique features.”(“SubClass”继承了“SuperClass”的属性和方法,并且还可以有自己独特的特性。)
- Polymorphism
- 记忆方法:“poly - ”有“多”的意思,“morphism”有“形态”的意思,在编程中表示“多态性”,即不同对象对同一消息有不同的响应方式。
- 例句:“Polymorphism allows different objects of related classes to respond to the same function call in different ways.”(多态性允许相关类的不同对象以不同方式对相同的函数调用做出响应。)
- Encapsulation
- 记忆方法:有“封装”的意思,将数据和操作数据的方法包装在一起,对外部隐藏内部实现细节。
- 例句:“Encapsulation in the
BankAccount
class hides the internal balance variable and provides public methods to access and modify it.”(“BankAccount”类中的封装隐藏了内部的余额变量,并提供公共方法来访问和修改它。)
六、数据结构相关单词
- Array
- 记忆方法:读音类似“呃瑞”,可以联想成“一系列”,在编程中是一组相同类型的数据元素的集合。
- 例句:“An array
numbers
is used to store a list of integers.”(一个数组“numbers”用于存储整数列表。)
- List
- 记忆方法:在日常英语中有“列表”的意思,在编程中是一种有序的数据结构,可以存储多个元素,元素类型可以不同。
- 例句:“The shopping list is implemented as a list data structure, containing items such as ‘apple’, ‘banana’ and ‘milk’.”(购物清单被实现为一个列表数据结构,包含诸如“苹果”、“香蕉”和“牛奶”等项目。)
- Stack
- 记忆方法:有“堆叠”的意思,是一种后进先出(LIFO)的数据结构,就像一摞盘子,最后放上去的最先被拿走。
- 例句:“The function call stack uses the stack data structure to manage the order of function calls and returns.”(函数调用栈使用栈数据结构来管理函数调用和返回的顺序。)
- Queue
- 记忆方法:有“队列”的意思,是一种先进先出(FIFO)的数据结构,就像排队买票,先来的先服务。
- 例句:“A queue is used to manage the order of tasks waiting to be processed, such as print jobs.”(队列用于管理等待处理的任务的顺序,如打印作业。)
- Tree
- 记忆方法:很形象,和自然界中的树相似,是一种非线性的数据结构,有根节点、分支和叶子节点。
- 例句:“A binary tree is a tree data structure where each node has at most two children.”(二叉树是一种树数据结构,其中每个节点最多有两个子节点。)
- Graph
- 记忆方法:在数学和编程中有“图”的意思,由顶点(vertex)和边(edge)组成,用于表示对象之间的关系。
- 例句:“A social network can be modeled as a graph, where users are vertices and friendships are edges.”(一个社交网络可以被建模为一个图,其中用户是顶点,友谊是边。)
七、数据库相关单词
- Database
- 记忆方法:“data”是数据,“base”有“基础、基地”的意思,合起来就是存储数据的地方。
- 例句:“The company’s customer information is stored in a database.”(公司的客户信息存储在一个数据库中。)
- Table
- 记忆方法:在数据库中,“table”是一张表,用于存储数据,就像现实生活中的表格。
- 例句:“The
employees
table stores information such as name, age and salary of each employee.”(“employees”表存储每个员工的姓名、年龄和工资等信息。)
- Column
- 记忆方法:在数据库表中,“column”是列,用于存储特定类型的数据,如姓名列、年龄列。
- 例句:“The ‘email’ column in the
users
table stores the email addresses of all users.”(“users”表中的“email”列存储所有用户的电子邮件地址。)
- Row
- 记忆方法:在数据库表中,“row”是行,代表一条记录,包含表中各个列的值。
- 例句:“Each row in the
orders
table represents a single order placed by a customer.”(“orders”表中的每一行代表一个客户下的单个订单。)
- Query
- 记忆方法:有“查询”的意思,在数据库中用于检索满足特定条件的数据。
- 例句:“The SQL query is used to select all the customers who live in a particular city.”(SQL查询用于选择所有居住在特定城市的客户。)
- Insert
- 记忆方法:有“插入”的意思,用于向数据库表中添加新的数据行。
- 例句:“The
insert
statement is used to add a new record into theproducts
table.”(“insert”语句用于向“products”表中添加一条新记录。)
- Update
- 记忆方法:有“更新”的意思,用于修改数据库表中已存在的数据。
- 例句:“The
update
statement is used to change the contact information of a customer in thecustomers
table.”(“update”语句用于更改“customers”表中一个客户的联系信息。)
- Delete
- 记忆方法:有“删除”的意思,用于从数据库表中移除数据行。
- 例句:“The
delete
statement is used to remove an old order record from theorders
table.”(“delete”语句用于从“orders”表中删除一个旧的订单记录。)
八、编程语言和工具相关单词
- Programming Language
- 记忆方法:“programming”是编程,“language”是语言,合起来就是用于编程的语言。
- 例句:“Python is a popular programming language used for web development, data analysis and more.”(Python是一种流行的编程语言,用于网络开发、数据分析等诸多领域。)
- Compiler
- 记忆方法:有“编译器”的意思,将高级编程语言编写的源代码转换为机器语言,以便计算机能够执行。
- 例句:“The C++ compiler is used to translate the C++ source code into executable machine code.”(C++编译器用于将C++源代码翻译成可执行的机器代码。)
- Interpreter
- 记忆方法:有“解释器”的意思,与编译器不同,它是逐行解释并执行源代码,而不是一次性全部编译。
- 例句:“Python uses an interpreter to execute the code line by line.”(Python使用解释器逐行执行代码。)
- IDE(Integrated Development Environment)
- 记忆方法:“Integrated”有“集成的”意思,“Development”是开发,“Environment”是环境,是集成了代码编辑、编译、调试等功能的开发环境。
- 例句:“Visual Studio Code is a popular IDE for many programming languages.”(Visual Studio Code是一种适用于许多编程语言的流行集成开发环境。)
- Debugger
- 记忆方法:有“调试器”的意思,用于帮助程序员查找和修复程序中的错误(bug)。
- 例句:“The debugger allows the programmer to step through the code and find the source of the error.”(调试器允许程序员逐行检查代码并找到错误的根源。)
- Version Control(e.g., Git)
- 记忆方法:“version”是版本,“control”是控制,用于管理项目的不同版本,如Git是一个流行的版本控制系统。
- 例句:“Git is used to track changes in the source code and manage different versions of the project.”(Git用于跟踪源代码中的更改并管理项目的不同版本。
补充
- Variable Declaration(变量声明)
- Declare:
- 记忆方法:读音为[dɪˈkleə®],与“宣告、声明”的意思紧密相连。在编程中,用于向编译器或解释器表明变量的存在及其类型。
- 例句:“You need to declare a variable before you can use it. For example, in Java, you can declare an integer variable like this:
int num;
”(在使用变量之前,你需要声明它。例如,在Java中,你可以像这样声明一个整数变量:int num;
)
- Initialize:
- 记忆方法:由“initial(最初的)”加上动词后缀“-ize”构成,意思是“初始化”。就是给变量赋初始值的过程。
- 例句:“It’s a good practice to initialize a variable when you declare it. For instance,
int count = 0;
initializes the variablecount
to 0.”(在声明变量时对其进行初始化是一个很好的做法。例如,int count = 0;
将变量count
初始化为0。)
- Declare:
- Variable Types(变量类型)
- Primitive(基本类型)
- 记忆方法:读音为[ˈprɪmətɪv],和“原始的、基本的”意思相关。在编程语言中,基本数据类型是最基础的数据类型,不能再分解为其他类型。
- 例句:“Integer, floating - point, character, and boolean are primitive data types in many programming languages.”(在许多编程语言中,整数、浮点数、字符和布尔值是基本数据类型。)
- Reference(引用类型)
- 记忆方法:有“参考、引用”的意思。引用类型的变量存储的是对象的引用(内存地址),而不是对象本身。
- 例句:“In languages like Java, objects are reference types. A variable of a reference type doesn’t hold the object’s value directly, but a reference to where the object is stored in memory.”(在像Java这样的语言中,对象是引用类型。引用类型的变量不直接保存对象的值,而是保存对象在内存中存储位置的引用。)
- Primitive(基本类型)
- Variable Scope(变量作用域)
- Scope:
- 记忆方法:读音为[skəʊp],本身就有“范围、界限”的意思。在编程中,变量作用域决定了变量在程序中的可见性和生命周期。
- 例句:“The scope of a local variable is limited to the block of code in which it is declared. For example, a variable declared inside a function can only be accessed within that function.”(局部变量的作用域仅限于声明它的代码块。例如,在一个函数内部声明的变量只能在该函数内部访问。)
- Block - scoped(块作用域)
- 记忆方法:“block”有“块、区块”的意思,块作用域变量只在特定的代码块(如
if
语句块、for
循环块等)内有效。 - 例句:“In JavaScript, variables declared with
let
andconst
are block - scoped. If you declare a variable inside afor
loop usinglet
, it won’t be accessible outside the loop.”(在JavaScript中,用let
和const
声明的变量是块作用域的。如果你在for
循环内部使用let
声明一个变量,在循环外部将无法访问它。)
- 记忆方法:“block”有“块、区块”的意思,块作用域变量只在特定的代码块(如
- Scope:
- Variable Modification(变量修改)
- Assign(赋值)
- 记忆方法:读音为[əˈsaɪn],和“分配、指派”有关。在编程中,赋值操作是将一个值赋给一个变量。
- 例句:“You can assign a new value to a variable. For example, in Python, you can write
x = 5
to assign the value 5 to the variablex
.”(你可以给一个变量赋一个新值。例如,在Python中,你可以写x = 5
来将值5赋给变量x
。)
- Increment(自增)
- 记忆方法:“in - ”表示“增加”,“crement”与“增长”有关。自增操作通常用于将变量的值增加1。
- 例句:“The
++
operator is used for incrementing a variable in languages like C and C++. For example,i++;
increments the value ofi
by 1.”(在C和C ++等语言中,++
运算符用于自增变量。例如,i++;
将i
的值增加1。)
- Decrement(自减)
- 记忆方法:与“increment”相反,“de - ”表示“减少”,用于将变量的值减少1。
- 例句:“The
--
operator is used for decrementing a variable. In Java,j--;
will decrease the value ofj
by 1.”(--
运算符用于自减变量。在Java中,j--;
会将j
的值减少1。)
- Assign(赋值)
- Variable Naming(变量命名)
- Identifier(标识符)
- 记忆方法:读音为[aɪˈdentɪfaɪə®],有“识别符、标识符”的意思。变量名就是一种标识符,用于在程序中唯一地标识一个变量。
- 例句:“A valid identifier in a programming language must follow certain rules. For example, it can’t start with a number in most languages and should not contain special characters like spaces.”(编程语言中的有效标识符必须遵循一定的规则。例如,在大多数语言中,它不能以数字开头,并且不应包含空格等特殊字符。)
- Convention(约定、惯例)
- 记忆方法:读音为[kənˈvenʃn],有“惯例、习俗”的意思。变量命名约定是程序员在命名变量时遵循的一些规则和习惯,以提高代码的可读性。
- 例句:“In Python, it’s a common naming convention to use lowercase letters and underscores for variable names, like
user_name
.”(在Python中,使用小写字母和下划线来命名变量是一种常见的命名约定,如user_name
。)
- Identifier(标识符)
语句
Role in Storing Data
- English Sentence: Variables serve as containers to hold various types of data within a program. For instance, in a program designed to manage student information, we can declare variables like “studentName” of type string to store the name of a student, “studentAge” of type integer to record the age, and “studentScore” of type float to keep track of the academic score. Just as we use boxes to store different items in real life, variables in programming are used to store different kinds of data values.
- Chinese Translation: 变量在程序中充当容器,用于存放各类数据。例如,在一个用于管理学生信息的程序中,我们可以声明诸如字符串类型的“studentName”变量来存储学生的姓名,整数类型的“studentAge”变量来记录学生的年龄,以及浮点类型的“studentScore”变量来追踪学生的学业成绩。就如同在现实生活中我们使用盒子来存放不同物品一样,编程中的变量被用于存储不同种类的数据值。
Facilitating Calculations and Operations
- English Sentence: They play a vital role in performing calculations and operations. Let’s take a simple arithmetic operation as an example. Suppose we want to calculate the sum of two numbers. We can declare two variables, say “num1” and “num2”, assign them specific values, and then use these variables in an expression to calculate the sum. In Python code, it might look like this:
num1 = 5; num2 = 3; sum_result = num1 + num2
. Here, variables make it convenient to conduct arithmetic operations and obtain the desired result. Moreover, in more complex programs involving multiple steps of calculations or logical operations, variables are essential for passing intermediate results from one part of the program to another. - Chinese Translation: 变量在执行计算和操作方面起着至关重要的作用。让我们以一个简单的算术运算为例。假设我们想要计算两个数字的总和,我们可以声明两个变量,比如“num1”和“num2”,给它们赋予特定的值,然后在表达式中使用这些变量来计算总和。在Python代码中,可能看起来像这样:
num1 = 5; num2 = 3; sum_result = num1 + num2
。在这里,变量使得进行算术运算并获得期望的结果变得方便。而且,在涉及多个计算步骤或逻辑操作的更复杂程序中,变量对于将中间结果从程序的一个部分传递到另一个部分是必不可少的。
Representing Program State
- English Sentence: Variables are used to represent the state of a program at any given time. In a game, for example, variables can denote the position of the game character on the screen, its health status, and the number of lives remaining. As the game progresses and the character moves, gets damaged, or loses a life, the values of these variables change accordingly, reflecting the current state of the game. In a C++ game program, we might have code like this:
int characterX = 100; int characterY = 100; int characterHealth = 100; int livesRemaining = 3;
. These variables together describe the state of the game character within the game world. - Chinese Translation: 变量被用于表示程序在任何给定时刻的状态。例如,在一款游戏中,变量可以表示游戏角色在屏幕上的位置、其健康状况以及剩余的生命数量。随着游戏的进行,当角色移动、受到伤害或者失去一条生命时,这些变量的值会相应地改变,从而反映游戏的当前状态。在一个C++游戏程序中,我们可能会有这样的代码:
int characterX = 100; int characterY = 100; int characterHealth = 100; int livesRemaining = 3;
。这些变量共同描述了游戏角色在游戏世界中的状态。
Enabling Code Reusability and Modularity
- English Sentence: Variables contribute to making code more reusable and modular. Consider a function that calculates the area of a rectangle. We can define the length and width of the rectangle as variables within the function. Then, whenever we need to calculate the area of different rectangles with various dimensions, we can simply call this function and pass in different values for the length and width variables. For example, in Java, we could have a function like this:
public static int calculateRectangleArea(int length, int width) { return length * width; }
. By using variables in this way, the same piece of code can be reused multiple times with different input values, making the overall program structure more modular and easier to maintain. - Chinese Translation: 变量有助于使代码更具可复用性和模块化。考虑一个计算矩形面积的函数,我们可以将矩形的长和宽定义为函数内的变量。然后,每当我们需要计算不同尺寸的矩形面积时,我们只需调用这个函数,并为长和宽变量传入不同的值即可。例如,在Java中,我们可能会有这样一个函数:
public static int calculateRectangleArea(int length, int width) { return length * width; }
。通过以这种方式使用变量,同一段代码可以使用不同的输入值多次复用,使得整个程序结构更具模块化,也更易于维护。