15
QuizMultiple Choice

Iteration — Unit test

Question 15 • VA-Information Technology Fundamentals B

Mika forgot to put in the function name in his function header for the code below. What would be the best function header?def draw(): forward(80) left(120) forward(80) left(120) forward(80) left(120)

Answer
A
def drawDiamond():
B
def drawTriangle():
C
def drawN():
D
def drawH():

Explanation

Each forward(80) draws one side, and the three left(120) turns create the angles needed to close an equilateral triangle. The function draws a triangle, so the best header is def drawTriangle().

AI-written and checked against the verified answer.

Previous
Next