QUESTION IMAGE
Question
question 4
you need to write a program that has karel take all the tennis balls where karel is standing if there are any there.
karel should end up with no tennis balls on that spot.
which control structure do you need to use?
for loop
while loop
if statement
if/else statement
none of them
Karel needs to keep taking tennis balls as long as there are balls at the spot. A While loop is appropriate as it will continue executing the block of code (taking balls) as long as a certain condition (presence of balls) is true. A For loop is used when you know the exact number of iterations in advance, which is not the case here. If and If/Else statements are for conditional execution based on a single - time check, not for repeated actions until a condition changes.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
B. While Loop