Browse all quizzes
ProgrammingGrade 4en

๐Ÿ› Reading, Predicting, and Debugging Code

Master the art of reading code like a detective! This quiz teaches you how to trace through simple programs, predict what they'll do, spot bugs like off-by-one errors and broken loops, and use systematic debugging to fix them. **What you'll learn:** - How to read and trace code step-by-step - Predict program output before running it - Spot common bugs: off-by-one errors, wrong conditions, missing loops - Use logic to debug and fix broken code

18 questions ยท play in your browser
No signup required โ€” try it for free.

Questions in this quiz

Answers hidden โ€” play to find out.

  1. Question 1

    Look at the following code. What will the variable result be after the code runs?

  2. Question 2

    In the code above, the loop adds the numbers 1, 2, 3, 4, and 5 together.

  3. Question 3

    Look at the following code. What will be printed?

  4. Question 4

    Which of these statements is true about the following code?

  5. Question 5

    This code will print the number 5.

  6. Question 6

    Look at the following code. What is the bug in this code?

  7. Question 7

    Look at the following code. What will the final value of total be?

  8. Question 8

    Look at the following code. What will be printed to the screen?

  9. Question 9

    This code will set the variable answer to 8.

  10. Question 10

    Look at the following code. What is the bug?

  11. Question 11

    Look at the following code. How many times will the loop print 'Hello'?

  12. Question 12

    This code will print the word 'Even' when x equals 4.

  13. Question 13

    Look at the following code. What will it print?

  14. Question 14

    Look at the following code. Identify the bug.

  15. Question 15

    An off-by-one error happens when a loop or condition is off by exactly one value, like using range(1, 5) when you meant range(1, 6).

  16. Question 16

    Look at the following code. What is the output?

  17. Question 17

    Look at the following code. What bug exists in this code?

  18. Question 18

    This code will print the numbers 1, 2, 3, 4, and 5.