• Foundation
  • 15 practice questions

Final self-assessment: programming concepts

Test yourself on the whole course: 15 questions with answers explained.

If something looks wrong, please tell us.

Attempt all 15 questions, then check your answers. These are a little harder than the checks after each lesson. Which lessons cover which questions: questions 1-3: lesson 1, "Algorithms and flowcharts"; questions 4-6: lesson 2, "Variables, data types and operators"; questions 7-9: lesson 3, "Making decisions: if and else"; questions 10-12: lesson 4, "Repeating steps: loops"; questions 13-15: lesson 5, "Functions, errors and ways of programming".

Final self-assessment

  1. 1. Which flowchart symbol is used to join parts of a chart?

    1. Diamond
    2. Oval
    3. Parallelogram
    4. Circle (connector)
    Show answer

    Answer: D. A small circle is the connector that joins parts of a flowchart. The oval is the terminator for start and stop.

  2. 2. Which of these is NOT a quality of a good algorithm?

    1. It keeps running without ever stopping
    2. Its steps are clear
    3. It has a definite start and end
    4. It produces output
    Show answer

    Answer: A. An algorithm must be finite, meaning it must stop. A process that never ends is not an algorithm.

  3. 3. An algorithm reads A and B, sets Sum = A + B, then prints Sum / 2. What is printed for A = 14 and B = 8?

    1. 22
    2. 7
    3. 15
    4. 11
    Show answer

    Answer: D. Sum = 14 + 8 = 22, and 22 / 2 = 11.

  4. 4. What is 47 % 6?

    1. 7
    2. 7.83
    3. 1
    4. 5
    Show answer

    Answer: D. 6 x 7 = 42 and 47 - 42 = 5, so the remainder is 5. 7 is the quotient, not the remainder.

  5. 5. Evaluate (10 == 10) AND NOT (4 > 9).

    1. False
    2. 10
    3. It cannot be evaluated
    4. True
    Show answer

    Answer: D. 10 == 10 is True. 4 > 9 is False, so NOT (4 > 9) is True. True AND True is True.

  6. 6. x = 25 % 7, then x = x + 2. What is the final value of x?

    1. 4
    2. 3
    3. 6
    4. 9
    Show answer

    Answer: C. 25 = 3 x 7 + 4, so 25 % 7 = 4. Then x = 4 + 2 = 6.

  7. 7. Grade rule: IF marks >= 80 print A; ELSE IF marks >= 60 print B; ELSE IF marks >= 40 print C; ELSE print Fail. What prints for marks = 60?

    1. B
    2. A
    3. C
    4. Fail
    Show answer

    Answer: A. 60 >= 80 is false; 60 >= 60 is true, so B prints. The boundary value 60 belongs to B because the test is >=.

  8. 8. The grade rule is written in the wrong order: IF marks >= 40 print C; ELSE IF marks >= 60 print B; ELSE IF marks >= 80 print A; ELSE print Fail. What prints for marks = 92?

    1. A
    2. B
    3. Fail
    4. C
    Show answer

    Answer: D. The first condition, 92 >= 40, is already true, and an else-if chain stops at the first true condition. So C prints, which shows why order matters.

  9. 9. IF n % 2 == 0 print Even ELSE print Odd. For which value of n does it print Odd?

    1. 14
    2. 21
    3. 0
    4. 36
    Show answer

    Answer: B. 21 % 2 = 1, so it prints Odd. 14, 0 and 36 all leave remainder 0, so they print Even.

  10. 10. total = 0; FOR i = 1 to 5: total = total + i x i. What is the final total?

    1. 15
    2. 55
    3. 25
    4. 30
    Show answer

    Answer: B. total goes 1, 5, 14, 30, 55 (1 + 4 + 9 + 16 + 25), so it is 55.

  11. 11. result = 1; FOR i = 1 to 6: result = result x i. What is the final result?

    1. 120
    2. 21
    3. 720
    4. 36
    Show answer

    Answer: C. result goes 1, 2, 6, 24, 120, 720. 120 would be the value after i = 5.

  12. 12. i = 3; DO: print i, then i = i + 1; WHILE i < 3. How many times is a number printed?

    1. Once
    2. 0 times
    3. 3 times
    4. It never stops printing
    Show answer

    Answer: A. A do-while runs the body first, so it prints 3 and makes i = 4. Then 4 < 3 is false, so it stops after one print.

  13. 13. Which kind of error gives no error message, so it must be found by careful testing?

    1. Logic error
    2. Syntax error
    3. Runtime error that stops the program
    4. A missing bracket
    Show answer

    Answer: A. A logic error lets the program run but gives wrong results, so no message appears. Syntax errors are reported by the translator and runtime errors stop the program.

  14. 14. A function square(n) returns n x n. What is square(3) + square(5)?

    1. 64
    2. 34
    3. 16
    4. 15
    Show answer

    Answer: B. square(3) = 9 and square(5) = 25, so the sum is 34. (64 would be square(3 + 5).)

  15. 15. In object-oriented programming, a program is built from objects that combine

    1. Only loops and conditions
    2. Only flowchart symbols
    3. Data and the actions on that data
    4. Only device drivers
    Show answer

    Answer: C. OOP builds a program from objects that combine data and actions; ideas include class, object, inheritance and encapsulation.

Revisit the lesson for any question you missed: questions 1-3: lesson 1, "Algorithms and flowcharts"; questions 4-6: lesson 2, "Variables, data types and operators"; questions 7-9: lesson 3, "Making decisions: if and else"; questions 10-12: lesson 4, "Repeating steps: loops"; questions 13-15: lesson 5, "Functions, errors and ways of programming".

Privacy · Terms · Refunds · Delivery