Olympiad · Practice · public practice problem
Builder division (School Level 2)
Computational Engineering
The loop that never ends
Difficulty 3 of 510 points in 4 partsSuggested time ~18 min (never timed here)
The problem
A drone simulator models battery level like this:
level = 100.0 # percent
minutes = 0
while level > 30:
level = level * 0.9
minutes = minutes + 1
print(minutes, round(level, 2))A second program tries to step time in tenths of a second:
t = 0.0
while t != 1.0:
t = t + 0.1Part (a) · 3 points
What value of
minutesdoes the first program print?(pure number)Tolerance: exactPart (b) · 3 points
What battery level does it print?
%Tolerance: ±0.01 %Part (c) · 2 points
Part (d) · 2 points · rubric with 2 criteria
Rewrite the second loop's condition so it is safe, and explain why your version works.
Written parts stay in your browser. Reveal the worked solution to mark yourself against the rubric.
Checked so far: 0 of 8 automatically marked points, plus 2 for written parts you mark yourself against the rubric. Nothing is saved.
Stuck? Hints, then the worked solution
Written with AI assistance. Review status: technically-checked (answers recomputed independently with units verified by automated tests); not yet reviewed by an educator or judge.