Unit 6: B2 Programming

Topic 6.3: Control structures and modularity Questions

Practice 20 exam-style questions for IB Computer Science Topic 6.3. Review the question stems below, then unlock the full Question Bank to access markschemes, model answers, and AI grading.

1Construct4 marks
2026
A ferry fare depends on how full the sailing is: it equals the initial price if under 10 per cent of tickets are sold, 1.5 times the initial price if 10 to 50 per cent are sold, and 3 times the initial price if more than 50 per cent are sold. The Sailing object holds seatsSold, capacity and basePrice. Construct the Java method updatedFare() that calculates and returns the fare.
Markscheme and model answer locked
Unlock Question
2Describe2 marks
2026
Describe what a function is.
Markscheme and model answer locked
Unlock Question
3Determine3 marks
2026
Determine what is wrong with this Python code. total = 0 print(total) total = price * quantity
Markscheme and model answer locked
Unlock Question
4Determine3 marks
2026
Determine the output of this Python code. s = 0 for i in range(1, 5): for j in range(1, 4): s = s + 1 print(s)
Markscheme and model answer locked
Unlock Question
5State3 marks
2026
State what this Python outputs. x = 1 while x < 20: x = x * 3 print(x)
Markscheme and model answer locked
Unlock Question
6Determine2 marks
2026
Determine the output of this Python code. n = 4 n = n + 1 n = n * n print(n)
Markscheme and model answer locked
Unlock Question
7Determine2 marks
2026
A program reads a number n once, then uses a counted loop to print n × 1, n × 2 and so on up to n × 12. Determine what would happen if the input statement were moved inside the loop.
Markscheme and model answer locked
Unlock Question
8Determine3 marks
2026
Determine what is wrong with this Java code. double total = 0; System.out.println(total); total = price * quantity;
Markscheme and model answer locked
Unlock Question
9Determine2 marks
2026
Determine the output of this Python code. a = 3 a = 10 b = a + 2 print(b)
Markscheme and model answer locked
Unlock Question
10Determine2 marks
2026
Determine the output of this Java code. int a = 3; a = 10; int b = a + 2; System.out.println(b);
Markscheme and model answer locked
Unlock Question
11Choose1 mark
2026
Choose the value of n after this Python code runs. n = 5 n = n * 2 n = n - 3
Markscheme and model answer locked
Unlock Question
12Choose1 mark
2026
Choose the value of n after this Java code runs. int n = 5; n = n * 2; n = n - 3;
Markscheme and model answer locked
Unlock Question
13Determine3 marks
2026
Determine what this Java code outputs when mark is 90. if (mark >= 40) { System.out.println("C"); } else if (mark >= 60) { System.out.println("B"); } else if (mark >= 80) { System.out.println("A"); }
Markscheme and model answer locked
Unlock Question
14Determine2 marks
2026
Determine the output of this Java code. int x = 2; int y = 3; int t = x; x = y; y = t; System.out.println(x + " " + y);
Markscheme and model answer locked
Unlock Question
15Determine2 marks
2026
Determine the output of this Java code. int n = 4; n = n * n; n = n + 1; System.out.println(n);
Markscheme and model answer locked
Unlock Question
16Determine2 marks
2026
Determine the output of this Java code. int a = 3; int b = a + 2; a = 10; System.out.println(b);
Markscheme and model answer locked
Unlock Question
17Determine2 marks
2026
Determine the output of this Java code. int n = 4; n = n + 1; n = n * n; System.out.println(n);
Markscheme and model answer locked
Unlock Question
18Determine3 marks
2026
Determine what this Python code outputs when mark is 90. if mark >= 40: print('C') elif mark >= 60: print('B') elif mark >= 80: print('A')
Markscheme and model answer locked
Unlock Question
19Determine3 marks
2026
Determine the output of this Python code. x = 7 if x > 5: if x > 10: print('big') else: print('medium') else: print('small')
Markscheme and model answer locked
Unlock Question
20Determine3 marks
2026
Determine the output of this Java code. int x = 7; if (x > 5) { if (x > 10) { System.out.println("big"); } else { System.out.println("medium"); } } else { System.out.println("small"); }
Markscheme and model answer locked
Unlock Question

Ready to practice Topic 6.3?

Get instant AI feedback on your answers, view detailed markschemes, and track your progress across all IB Computer Science topics.

Start Practising Now