For Kid's Programming: Common words (Part 2)

29 Feb 2020

I sort out 100 high-frequency words that I use in programming, Python and C++. Here are the second ten.

python

Chinese explanation: 蟒蛇,一种编程语言的名字。

python这个单词直译过来是“蟒蛇”,很多介绍python的书也用各种形象的蟒蛇作为封面,但严格来说这种语言的名字不能叫做蟒蛇。python的创始人Guido van Rossum非常喜欢看英国的超现实戏剧团体Monty Python创作的肥皂剧Monty Python's Flying Circus,把这门语言命名为python是为了纪念Monty Python。

integer

Chinese explanation: 整型、整数,编程语言中一般简写为int。

1
# python
2
# python does not need to explicitly define the data type
3
a = 1
4
b = 2
5
c = a + b
6
print(c)
1
// c++
2
int a = 1;
3
int b = 2;
4
int c = a + b;
5
cout << c << endl;

float

Chinese explanation: 浮动,在编程语言中代表浮点型,用来表示小数。之所以叫做浮点型是和定点型对应的,简言之就是计算机用二进制表示小数时,小数点的位置是根据具体的数字表达而浮动变化的。

1
# python
2
a = 5
3
b = 3.14
4
c = a * a * b
5
print(c)
1
// c++
2
float a = 5;
3
float b = 3.14;
4
float c = a * a * b;
5
cout << c << endl;

string

Chinese explanation: 串,在编程语言中用来表示字符(串),既多个字符串起来,有些语言或标准库用法简写为str。

1
# python
2
a = "I am a string!"
3
print(s)
4
# you can case a string to an integer with int()
5
a = "123"
6
b = 10
7
c = int(a) + b
8
print(c)
1
// c++
2
string a = "I am a string!";
3
cout << a << endl;

list / append

Chinese explanation: 清单 / 附加,在python中用来将多个同一类型的数据列入一个清单中。

1
# python
2
nums = [1, 2, 3, 4, 5, 6]
3
nums.append(7)
4
print(nums)
5
print(nums[1])
6
for n in nums:
7
    print(n)

range

Chinese explanation: 范围,用于在指定范围内构造一组数据。

1
# python
2
for i in range(5):
3
    print(i)

sum

Chinese explanation: 和,总和,一般用于数字求和。

1
# python
2
nums = [1, 2, 3, 4, 5, 6]
3
total = sum(nums)
4
print(total)

pass

Chinese explanation: 过,通过,在python中表示什么都不做。

1
# python
2
while True:
3
    pass

define

Chinese explanation: 限定,下定义,编程语言中用于定义函数或其他抽象,python中简写为def。

1
# python
2
def func():
3
    return "Hello!"
4
print(func())
1
// c++
2
#define _A_MACRO_

return

Chinese explanation: 返回,编程语言中一般用于函数返回最终运算结果。

1
# python
2
def func(name):
3
    return "Hello " + name
4
print(func("Li Bo"))
1
// c++
2
int getTotal(int a, int b)
3
{
4
    int c = a + b;
5
    return c;
6
}