파이썬의 터틀 그리기 연습한 내용입니다.
무작위 지역에 도형을 그리는 내용으로 만들어 봤습니다.
[python]
# -*- coding: utf-8 -*-
import turtle
import random
t=turtle.Pen()
t.shape("turtle")
b=0
while b < 20 :
a=0
x=int(random.randrange(-300,300))
y=int(random.randrange(-300,300))
c=int(random.randrange(3,12))
i=int(360/c)
b=b+1
t.pendown()
while a < c+1 :
t.forward(i)
t.right(i)
a += 1
if a == c :
break
t.penup()
t.goto(x,y)
[/python]