Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question 2 of 10 what is the purpose of the while loop in this program?…

Question

question 2 of 10
what is the purpose of the while loop in this program?
on start
set background color to
set fish to sprite of kind player
move fish with buttons
set fish stay in screen
set life to 1
set level to 1
while life ≠ 0
do
call playlevel

a. to call the playlevel function exactly two times
b. to call the playlevel function so long as the life value is not equal
to 0
c. to call the playlevel function exactly one time
d. to repeatedly call the playlevel function forever

Explanation:

Brief Explanations

A while loop in programming executes the code block (here, calling playLevel) as long as the condition is true. The condition here is life ≠ 0. Option A is wrong as there's no guarantee of two calls. Option C is wrong because a while loop with a true condition (initially life = 1 ≠ 0) will repeat, not just once. Option D is wrong because the loop stops when life = 0, not forever. So the correct option is B.

Answer:

B. To call the playLevel function so long as the life value is not equal to 0