Lesson 34: Find the errors
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Be the tester
- A program can run without a crash and still do the wrong thing: a logic error.
- Run each program, look at what the robot does, and compare it with what it should do.
- Fix one error at a time and run again. Press Map 2 and Map 3 to test with other data.
Words for this lesson
| Word | Meaning |
|---|---|
| syntax error | breaks the rules of Python: the program does not start |
| logic error | the program runs but gives the wrong result |
| test data | a case where you know the right answer |
| correction | the fixed line |
English
Where is the error?
| What you see | Look at |
|---|---|
| a side is missing | how many times the loop runs |
| the corners are wrong | the angle of each turn |
| the count is always 0 or 1 | where the count is set to 0 |
| the count is a little too small | does the loop visit every item? |
English
In the exam
- 0478/22/F/M/24 Q5(a): identify three errors in an algorithm and suggest corrections. Mark scheme: OUTPUT should be INPUT, OR should be AND, and NEXT should be ENDIF. Write the line number, what is wrong, and the corrected line.
- 0478/22/M/J/23 Q7(b): three errors in a check-digit algorithm. Mark scheme: use the array element, not the whole array; look for −1 to stop; start the output loop at 1, not 0. Like your second program, these are errors in what is counted and how many times the loop runs.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
This program should draw a square with 400 mm sides and end where it started, facing heading 0. It has two errors. Run it, look at the drawing, and correct the errors.
実行ボタンをクリックして出力を確認してください。
難易度 4/5 · 280 コイン + 今日初回達成時の小ボーナス
This program should drive over a row of 6 tiles, 200 mm apart, and print how many are red, for example Red tiles: 4. It has three errors. Find them and correct them. Map 2 and Map 3 show other rows.
実行ボタンをクリックして出力を確認してください。