| English | 释义 | 拼音 |
|---|---|---|
| bug/bʌɡ/ | 缺陷 | quē xiàn |
| debugging/ˈdiːbʌɡɪŋ/ | 调试 | tiáo shì |
| syntax error/ˈsɪntæks ˈerə/ | 语法错误 | yǔ fǎ cuò wù |
| logic error/ˈlɒdʒɪk ˈerə/ | 逻辑错误 | luó jí cuò wù |
| runtime error/ˈrʌntaɪm ˈerə/ | 运行时错误 | yùn xíng shí cuò wù |
| overflow error/ˌəʊvəˈfləʊ ˈerə/ | 溢出错误 | yì chū cuò wù |
| edge case/edʒ keɪs/ | 边界情况 | biān jiè qíng kuàng |
| expected output/ekˈspektɪd ˈaʊtpʊt/ | 预期输出 | yù qī shū chū |
Every program has bugs
- No matter how careful the team is, programs contain mistakes.
- A mistake in a program is a bug 缺陷.
- Finding and fixing bugs is called debugging 调试.
- Skilled debugging is one of the most valuable abilities a programmer can build.
Which kind of error?
A syntax error stops the program running; a logic error runs but gives the wrong answer; a runtime error crashes it partway; an overflow error exceeds storage.
The work of finding and fixing mistakes in a program is called ______.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
A mistake is a bug; fixing bugs is debugging.
A missing bracket that stops the program from running is a:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Breaking the language's rules is a syntax error.
Why are logic errors often the hardest to find?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Nothing obviously breaks, so you must compare output to what you expected.
The main kinds of error
- A syntax error 语法错误 breaks the language's rules (a missing bracket) — the program refuses to run.
- A logic error 逻辑错误 runs but gives the wrong result, because the instructions do not match the plan.
- A runtime error 运行时错误 crashes the program while it runs — like dividing by zero.
- An overflow error 溢出错误 happens when a value grows too large for its storage space.

A trace table records each variable's value as the program runs, to find bugs
Testing with edge cases (empty input, very large numbers) helps find hidden bugs.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Bugs often hide at the limits of what a program expects.
To spot a bug in a test, you compare the actual output with the:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
A difference between actual and expected output points to a bug.
How to find them
- Test with many inputs, including unusual ones — a very large number, empty input, or an edge case 边界情况 at the limit.
- Compare the actual output with the expected output 预期输出; a difference points to a bug.
- Add temporary print statements to see internal values, so you find where it first goes wrong.
- Divide and check: confirm one part is correct, then narrow down the rest.
After fixing a bug, you only need to re-test the line you changed.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
False. A fix can create a new bug elsewhere, so you should re-test the whole program after changing it.
Fix, then re-test
- Logic errors are the hardest — nothing obviously "breaks," the answer is just wrong.
- Fixing one bug can create another.
- So after every correction, re-test the whole program.
- Careful, repeated testing turns a rough prototype into software people can trust.
"It ran" is not "it's correct." A logic error runs with no crash and no message — the program looks fine but the answer is wrong. The only way to catch it is to compare the output with what you expected, not just check that it ran.
Worked example: finding a logic error
A program should find the average of a list of test scores. For the list [80, 90, 70] it prints 60 instead of 80. The code adds each score to a sum, then divides the sum by (length of list + 1). Classify and fix the bug.
- The program runs and prints a result, so it is not a syntax or runtime error: it is a logic error. Checking by hand: the sum is 240, and $240\div(3+1)=60$, so the divisor is wrong.
- Fix: divide by the length of the list: $240\div3=80$. Then test with more cases, including an edge case such as an empty list, which would cause a runtime error (division by zero) unless the program checks for it first.
A program crashes with "division by zero" when the user enters 0. This is:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
It happens while the program is running.
Testing only typical inputs is enough to find most bugs.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Edge cases and unusual inputs reveal many bugs.
A bug is a mistake; fixing bugs is debugging. A syntax error stops the program running, a logic error runs but gives the wrong answer, a runtime error crashes it partway, and an overflow error exceeds storage. Find bugs by testing many inputs (especially edge cases) against the expected output, and always re-test after a fix.