Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

2. Write a program to draw this. Assume the innermost square is 20 units per side, and each successive square is 20 units bigger, per side, than the one inside it.

import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle()

def draw_square(t,size):
    for i in range(4):
        tess.forward(size)
        tess.left(90)

size = 20
for j in range(3):
   tess.pensize(3)
   draw_square(tess,size)
   size = size + 20
   tess.penup()
   tess.goto(-20, -20)
   tess.pendown()

wn.mainloop()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Write #program #draw #Assume #innermost #square #units #successive #square #units
ADD COMMENT
Topic
Name
8+9 =