Write a program that uses the turtle module and a for loop to draw something. It doesn’t have to be complicated, but draw something different than we have done in the past.
Source Code:
Output:
Code in text format (See above image of code for indentation):
#import turtle module
import turtle
#program to print spiralsquare
#side size 6
side=6
#create a turtle screen
window=turtle.Screen()
#turtle object
dr=turtle.Turtle()
dr.color("blue")
#for loop iterates 10 times
for i in range(10):
#inner loop iterates 4 times to print square
for j in range(4):
#draw a forward line of size 6
dr.fd(side)
#change direction 90 degrees
dr.left(90)
#next square size increases
side=side+5
Get Answers For Free
Most questions answered within 1 hours.