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

27 Feb 2020

Learning English is the first task of learning programming for children in non-native English speaking countries.

Some parents ask me:

how can I get my child to learn programming well?

What if he/she is bad at math or logic?

……

But I firmly believe that learning English is the first task of learning programming for children in no-native English speaking countries, especially in China. At least some basic words. Because the programming language is based on English, and the graphics programming named Cat or Dog is not for kids, it's for adults.

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

print / out

Chinese explanation: 打印/输出, 在计算机屏幕上打印出一些字符。以下例子分别在python和c++程序中打印Newssit字符:

1
# python
2
print("Nessit")
1
// c++
2
cout << "Nessit" << endl;

input / in

Chinese explanation: 输入,在程序运行时获取输入的内容。

1
# python
2
content = input("Please type in some words: ")
1
// c++
2
string content;
3
cin >> content;

true / false

Chinese explanation: 真的 / 假的

1
# python
2
result_1 = True
3
resutl_2 = False
1
// c++
2
bool result1 = true;
3
bool result2 = false;

if / else

Chinese explanation: 如果 / 其他的(否则)

1
# python
2
if ( True ):
3
    print("Yes")
4
else:
5
    print("No")
1
// c++
2
if(true)
3
    cout << "Yes" << endl;
4
else
5
    cout << "No" << endl;

for

Chinese explanation: 对于、关于,编程语言中表示 for 循环

1
# python
2
for word in words:
3
    print(word)
1
// c++
2
for(auto word : words)
3
{
4
    cout << word << endl;
5
}

while

Chinese explanation: 当……的时候,编程语言中表示 while 循环

1
# python
2
i = 0
3
while(i < 10):
4
    print(i)
5
    i = i + 1
1
// c++
2
int i = 0;
3
while(i < 10)
4
{
5
    cout << i << endl;
6
    ++i;
7
}

continue

Chinese explanation: 继续、持续,用在 for / while 循环中,continue以后的语句不再执行,直接开始下一次循环。

1
# python
2
# the following program does not print 3
3
i = 0
4
while(i < 10):
5
    if(i == 3):
6
        continue
7
    print(i)
1
// c++
2
int i = 0;
3
while(i < 10)
4
{
5
    if(i == 3)
6
        continue;
7
    cout << i << endl;
8
}

break

Chinese explanation: 间断、打破,用在 for / while 循环中,遇到break循环立即结束,继续执行循环体后面的语句,既跳出循环。

1
# python
2
while(True):
3
    content = input("Please type in some words: ")
4
    if(content == "quit"):
5
        break
6
    else
7
        print(content)
1
// c++
2
while(true)
3
{
4
    cin >> content;
5
    if(content == "quit")
6
        break;
7
    cout << content << endl;
8
}

exit

Chinese explanation: 退出,退出/中断某个程序。

1
# python
2
while(True):
3
    content = input("Please type in some words: ")
4
    if(content == "exit"):
5
        exit()
6
    else
7
        print(content)

from / import

Chinese explanation: 从/导入,用于导入外部文件(库),以调用外部文件中提供的方法。

1
# python
2
from newssit import say
3
say("Hello python!")