Ask Question

What does the following program do?

import turtle

def main ():

turtle. hideturtle ()

square (100,0,50,'blue')

def square (x, y, width, color):

turtle. penup ()

turtle. goto (x, y)

turtle. fillcolor (color)

turtle. pendown ()

turtle. begin_fill ()

for count in range (2):

turtle. forward (width)

turtle. left (90)

turtle. end_fill ()

main ()

It draws 2 blue lines.

A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right. B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right. C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner. D) Nothing since you cannot call a function with turtle graphics corner

+2
Answers (1)
  1. 10 January, 14:37
    0
    C

    Explanation:

    It draws the blue square at coordinates (100,0) 50 pixel wide, and in the lower-left corner. You should know that the lower-left corner of the square should be at position x, y. Hence, the answer.

    And this is true for any shape that you draw using turtle graphics in Python.

    You should also know the function format of python, and how it is defined, declared and called. The penup command tells the turtle to not show what is drawn, or hide the ink. The pen down is just opposite to this.

    The count is an inbuilt function that counts and can be used as above with range to create a for the look. forward moves the cursor according to width mentioned.

    See how to pen down is called before beginning fill. And how we move to x, y using go to, and how the penup is used to hide ink while fill color is in effect, and we move to x, y.

    End fill ends the process.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What does the following program do? import turtle def main (): turtle. hideturtle () square (100,0,50,'blue') def square (x, y, width, ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers