Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 1 which of the following is the correct way to have karel pai…

Question

question: 1 which of the following is the correct way to have karel paint a red square using the paint function?
option 1: paint_red()
option 2: paint_color.red()
option 3: paint(color
ed\)
option 4: paint(colorred)

Explanation:

Brief Explanations

In Karel programming (a beginner CS environment), the paint function takes a color value passed as a string inside brackets, formatted as paint(color["color_name"]). The other options use incorrect syntax: paint_red() is a non-standard custom function name, paint_color.red() uses invalid dot notation for this context, and paint(color[red]) omits quotes around the color string, which would be treated as an undefined variable.

Answer:

○ paint(color["red"])