To draw a Spiral using Python Turtle Graphics - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Saturday, June 27, 2020

To draw a Spiral using Python Turtle Graphics







Question

To draw a Spiral using Python Turtle Graphics.

Sample TestCase Expected Output

  










Answer:



# import turtle library
import turtle             
my_wn = turtle.Screen()
my_wn.bgcolor("light blue")
my_wn.title("Turtle")
my_pen = turtle.Turtle()
my_pen.color("black")
def my_sqrfunc(size):
   for i in range(4):
      my_pen.fd(size)
      my_pen.left(90)
      size = size - 5
my_sqrfunc(146)
my_sqrfunc(126)
my_sqrfunc(106)
my_sqrfunc(86)
my_sqrfunc(66)
my_sqrfunc(46)
my_sqrfunc(26)

Follow Us For More...


No comments:

Post a Comment