Python Questions and Answers – Turtle Module – 3

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

1. Which of the following functions results in an error?
a) turtle.shape(“turtle”)
b) turtle.shape(“square”)
c) turtle.shape(“triangle”)
d) turtle.shape(“rectangle”)
View Answer

Answer: d
Explanation: The functions shown above will change the arrow to the shape mentioned. The functions turtle.shape(“turtle”), turtle.shape(“square”) and turtle.shape(“triangle”) are valid whereas the function turtle.shape(“rectangle”) is invalid.

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

import turtle
t=turtle.Pen
t.tilt(75)
t.forward(100)

a) A straight line of 100 units tiled at 75 degrees from the horizontal
b) A straight line of 100 units tilted at 15 degrees from the horizontal
c) A straight line of 100 units lying along the horizontal
d) Error
View Answer

Answer: c
Explanation: The function turtle.tilt(75) will tilt the turtle. But the straight line (of 100 units) is drawn along the horizontal. Hence the output of the code shown above is a straight line of 100 units lying along the horizontal.
advertisement
advertisement

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

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
import turtle
t=turtle.Pen()
t.backward(100)
t.penup()
t.right(45)
t.isdown()

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

Answer: b
Explanation: In the code shown above, we have used the function t.penup() to life the pen from the canvas. However, we have not used the function t.pendown() to keep the pen back down. The function turtle.isdown() returns True if the pen is down and False if the pen is not down. Hence the output is False.
advertisement

4. The function used to alter the thickness of the pen to ‘x’ units:
a) turtle.width(x)
b) turtle.span(x)
c) turtle.girth(x)
d) turtle.thickness(x)
View Answer

Answer: a
Explanation: The function turtle.width(x) is used to alter the thickness of the pen to ‘x’ units. The function turtle.span(x), turtle.girth(x) and turtle.thickness(x) are invalid.

5. What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

advertisement
import turtle
t=turtle.Pen()
t.goto(100,0)
t.towards(0,0)

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

Answer: b
Explanation: The function t.towards(x,y) returns the angle between the line to the line specified by (x,y). Hence the output will be 180.0.

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

import turtle
t=turtle.Pen()
t.position()
(100.00,0.00)
t.goto(100,100)
t.distance(100,0)

a) 0.0
b) Error
c) 100.0, 100.0
d) 100.0
View Answer

Answer: d
Explanation: The distance() function returns the distance between the turtle to the given vector. Hence the output of the code shown above is 100.0.

7. The output of the following Python code will result in a shape similar to the alphabet ___________

import turtle
t=turtle.Turtle()
t1=turtle.Turtle()
t.left(45)
t1.left(135)
t.forward(100)
t1.forward(100)

a) V
b) Inverted V
c) X
d) T
View Answer

Answer: a
Explanation: In the code shown above, two pens have been used to create a shape similar to the alphabet ‘V’. The angle between the two straight lines is 90 degrees.

8. The output of the following Python code is similar to the alphabet _______________

import turtle
t=turtle.Pen()
t1=turtle.Pen()
t2=turtle.Pen()
t.forward(100)
t1.forward(100)
t2.forward(100)
t1.left(90)
t1.forward(75)
t2.right(90)
t2.forward(75)

a) X
b) N
c) T
d) M
View Answer

Answer: c
Explanation: In the above code, three pens have been used to create a shape similar to the letter ‘T’. All the three straight lines are mutually perpendicular.

9. The following Python code will result in an error.

import turtle
t=turtle.Pen()
t.speed(-45)
t.circle(30)

a) True
b) False
View Answer

Answer: b
Explanation: Although a negative speed is not possible, the code shown above does not result in an error. Hence, the answer is False.

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

import turtle()
t=turtle.Pen()
t.goto(50,60)
t1=t.clone()
t1.ycor()

a) 0.0
b) 50.0
c) 60.0
d) Error
View Answer

Answer: c
Explanation: The function clone() is used to create a clone of the turtle, having the same properties such as position, coordinates etc. Hence, the properties of the t and t1 are the same in the code shown above. The function ycor() returns the y-coordinate of the turtle. Hence the output of the code is 60.0.

11. What will be the output shape of the following Python code?

import turtle
t=turtle.Pen()
for i in range(0,6):
	t.forward(100)
	t.left(60)

a) Hexagon
b) Octagon
c) Pentagon
d) Heptagon
View Answer

Answer: a
Explanation: The code shown above creates a six-sided polygon. The output shape of the code shown above is will be a hexagon.

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

import turtle
t=turtle.Pen()
t.resizemode(“sanfoundry”)
t.resizemode()

a) user
b) auto
c) nonresize
d) error
View Answer

Answer: c
Explanation: When not explicitly specified as auto or user, no adaption of the turtle’s appearance takes place and the mode is ‘noresize’. Hence the output of the code is: noresize.

Sanfoundry Global Education & Learning Series – Python.

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

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.