Python Questions and Answers – Turtle Module – 2

This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Turtle Module – 2”.

1. What will be the output of the following Python code?

import turtle
t=turtle.Pen()
t.color(0,0,1)
t.begin_fill()
t.circle(15)
t.end_fill()

a) Error
b) A circle filled in with the colour red
c) A circle filled in with the colour blue
d) A circle filled in with the colour green
View Answer

Answer: c
Explanation: The function t.colour(0, 0, 1) is used to fill in the colour blue into any given shape. Hence the output of the code shown above will be a circle filled in with the colour blue.
advertisement
advertisement

2. Which of the following functions can be used to make the arrow black?
a) turtle.color(0,1,0)
b) turtle.color(1,0,0)
c) turtle.color(0,0,1)
d) turtle.color(0,0,0)
View Answer

Answer: d
Explanation: The function turtle.color(0,0,0) can change the colour of the arrow. The function turtle.color(0,1,0) will make the arrow green. The function turtle.color(1,0,0) will make the arrow red. The function turtle.color(0,0,1) will make the arrow blue. The function turtle.color(0,0,0) will make the arrow black.

3. What will be the output of the following Python code?

Note: Join free Sanfoundry classes at Telegram or Youtube
import turtle
t=turtle.Pen()
t.color(1,1,1)
t.begin_fill()
for i in range(0,3):
	t.forward(100)
	t.right(120)
              t.end_fill()

a) Blank page
b) A triangle filled in with the colour yellow
c) A triangle which is not filled in with any colour
d) Error
View Answer

Answer: a
Explanation: The code shown above will result in a blank page. This is because the command turtle.color(1,1,1) eliminates the arrow from the page. Hence all the commands after this command are ineffective.

advertisement

4. What will be the output of the following Python code?

import turtle
t=turtle.Pen()
t.color(0,1,0)
t.begin_fill()
for i in range(0,4):
	t.forward(100)
	t.right(90)

a) A square filled in with the colour green
b) A square outlined with the colour green
c) Blank canvas
d) Error
View Answer

Answer: c
Explanation: The output shape of the code shown above is a square, outlined with the colour green, but not filled in with any colour. This is because we have not used the command t.end_fill() at the end.
advertisement

5. In which direction is the turtle pointed by default?
a) North
b) South
c) East
d) West
View Answer

Answer: c
Explanation: By default, the turtle is pointed towards the east direction. We can change the direction of the turtle by using certain commands. However, whenever the turtle is reset, it points towards east.

6. The command used to set only the x coordinate of the turtle at 45 units is:
a) reset(45)
b) setx(45)
c) xset(45)
d) xreset(45)
View Answer

Answer: b
Explanation: The command setx(45) is used to set the x coordinate of the turtle. Similarly, the command sety() is used to set the y coordinate of the turtle. The function reset() takes two values as arguments, one for the x-coordinate and the other for the y-coordinate.

7. Which of the following functions returns a value in degrees, counterclockwise from the horizontal right?
a) heading()
b) degrees()
c) position()
d) window_height()
View Answer

Answer: a
Explanation: The function heading() returns the heading of the turtle, which is a value in degrees counterclockwise from the horizontal right. This measure will be in radians if radians() has been called.

8. What will be the output of the following Python code?

import turtle
t=turtle.Pen()
t.right(90)
t.forward(100)
t.heading()

a) 0.0
b) 90.0
c) 270.0
d) 360.0
View Answer

Answer: c
Explanation: The output of the code shown above will be 270.0. The function heading() returns the heading of the turtle, a value in degrees, counterclockwise from the horizontal right. The output shape of this code is a straight line pointing downwards.

9. What will be the output of the following Python code?

import turtle
t=turtle.Pen()
t.clear()
t.isvisible()

a) Yes
b) True
c) No
d) False
View Answer

Answer: b
Explanation: The function t.clear() returns a blank canvas, without changing the position of the turtle. Since the turtle is visible on the blank canvas, the output of this code is: Yes.

10. What will be the output of the following Python code?

import turtle
t=turtle.Pen()
t.forward(100)
t.left(90)
t.clear()
t.position()

a) 0.00, 90.00
b) 0.00, 0.00
c) 100.00, 90.00
d) 100.00, 100.00
View Answer

Answer: d
Explanation: The output of the code shown above is 100.00, 100.00. The function clear() is used to erase the entire canvas and redraw the turtle. However, the position of the turtle is not changed.

Sanfoundry Global Education & Learning Series – Python.

To practice all areas of Python, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.