- 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. Which flowchart symbol is used to join parts of a chart?
- Diamond
- Oval
- Parallelogram
- 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. Which of these is NOT a quality of a good algorithm?
- It keeps running without ever stopping
- Its steps are clear
- It has a definite start and end
- 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. An algorithm reads A and B, sets Sum = A + B, then prints Sum / 2. What is printed for A = 14 and B = 8?
- 22
- 7
- 15
- 11
Show answer
Answer: D. Sum = 14 + 8 = 22, and 22 / 2 = 11.
-
4. What is 47 % 6?
- 7
- 7.83
- 1
- 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. Evaluate (10 == 10) AND NOT (4 > 9).
- False
- 10
- It cannot be evaluated
- 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. x = 25 % 7, then x = x + 2. What is the final value of x?
- 4
- 3
- 6
- 9
Show answer
Answer: C. 25 = 3 x 7 + 4, so 25 % 7 = 4. Then x = 4 + 2 = 6.
-
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?
- B
- A
- C
- 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. 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?
- A
- B
- Fail
- 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. IF n % 2 == 0 print Even ELSE print Odd. For which value of n does it print Odd?
- 14
- 21
- 0
- 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. total = 0; FOR i = 1 to 5: total = total + i x i. What is the final total?
- 15
- 55
- 25
- 30
Show answer
Answer: B. total goes 1, 5, 14, 30, 55 (1 + 4 + 9 + 16 + 25), so it is 55.
-
11. result = 1; FOR i = 1 to 6: result = result x i. What is the final result?
- 120
- 21
- 720
- 36
Show answer
Answer: C. result goes 1, 2, 6, 24, 120, 720. 120 would be the value after i = 5.
-
12. i = 3; DO: print i, then i = i + 1; WHILE i < 3. How many times is a number printed?
- Once
- 0 times
- 3 times
- 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. Which kind of error gives no error message, so it must be found by careful testing?
- Logic error
- Syntax error
- Runtime error that stops the program
- 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. A function square(n) returns n x n. What is square(3) + square(5)?
- 64
- 34
- 16
- 15
Show answer
Answer: B. square(3) = 9 and square(5) = 25, so the sum is 34. (64 would be square(3 + 5).)
-
15. In object-oriented programming, a program is built from objects that combine
- Only loops and conditions
- Only flowchart symbols
- Data and the actions on that data
- 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".
Sign in to keep track of the lessons you finish.