터틀 라이브러리를 t로 불러서 함수를 가져왔다.
터틀에는 다양한 함수들이 있다.
fill 함수를 통해서 초록색 사각형 색칠
네 가지 색을 리스트에 넣어서 반복문에서 하나씩 꺼내주었다.
윈도우 마크 최종코드
from turtle import *
c = ["green", "yellow", "red", "blue"]
for kk in range(4) :
color(c[kk])
begin_fill()
for ii in range(4):
fd(100)
left(90)
end_fill()
right(90)
penup()
fd(30)
pendown()
Python
복사
컬러 물방울
from turtle import *
import random as rd
speed(20)
colormode(255)
for ii in range(100) :
x = rd.randint(-300, 300)
y = rd.randint(-500, 500)
r = rd.randint(0, 255)
g = rd.randint(0, 255)
b = rd.randint(0, 255)
k = rd.randint(10, 80)
color(r,g,b)
penup()
goto(x, y)
pendown()
begin_fill()
circle(k)
end_fill()
Python
복사