QUESTION IMAGE
Question
question 2
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
The program needs to perform one action (take a ball) if a condition (ball is present) is true and another action (put down a ball) if the condition is false. An If/Else statement is used for such conditional - based two - way actions. Loops (For and While) are used for repetitive actions, and an If statement only has an action for the true condition without a defined action for the false condition.
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
D. If/Else statement