A wind tunnel test rig runs the code shown, which is intended to count down from 8 to 1.
count = 8
while count > 0:
print(count)
why this code does not terminate.
Practice IB Computer Science (First Exam 2027) Topic B2.3 Programming Constructs with authentic exam-style questions for both SL and HL students. This question bank focuses on the exact syllabus content for B2.3 Programming Constructs and mirrors Paper 1, 2 style where relevant.
Get instant solutions, detailed explanations, and build confidence with questions aligned to IB examiner expectations.
A wind tunnel test rig runs the code shown, which is intended to count down from 8 to 1.
count = 8
while count > 0:
print(count)
why this code does not terminate.
A wetland bird survey reads counts from an observer until a count of -1 signals the end, then reports the mean. The function next_count() is provided elsewhere and returns the next count.
total = 0seen = 0value = next_count()while value != -1: total = total + value seen = seen + 1print(total / seen)…
A cheese maturing store must report whether a wheel is ready.
the difference between a selection structure using if alone and one using if together with else.
A plant nursery uses the function shown, which is intended to return True when every label in a list has been printed.
def all_printed(labels):
for i in range(len(labels)):
if labels[i] == True:
return True
else:
return False
(a) the value returned by the call all_printed([False, True, True]).
(b) why the function does not test every label, and the correct structure.
A sawmill records the length in centimetres of each log cut during a shift in a 1D list. a function that is passed this list and returns the mean length, returning 0 if the list is empty. You must not use any built-in function that totals a sequence.