Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 1 you need to write a program where karel will take a ball if…

Question

question: 1
you need to write a program where karel will take a ball if there is a ball present, otherwise karel should put down a ball.
which control structure do you need to use?
○ for loop
○ while loop
○ if statement
○ if/else statement
○ none of these

Explanation:

Brief Explanations

The task requires Karel to perform one action (take a ball) if a condition (ball present) is true, and a different action (put down a ball) if the condition is false. This two-branch conditional logic is exactly what an If/Else statement is designed to handle. Loops are for repeated actions, a basic If statement only handles one conditional action, not the alternative.

Answer:

If/Else statement