728x90
반응형
import turtle
t = turtle.Turtle()
t.speed(0)
def draw_circle(x, y):
t.penup()
t.goto(x, y)
t.pendown()
n = 50
t.circle(n) # 반지름이 100인 원을 그린다.
def draw_polygon(x, y, pn):
n = 50 + ((8-pn)**2.4) # 대략적으로 크기를 비슷하게 하기 위해 한변의 길이 계산
t.penup()
t.goto(x-(n/2), y)
t.pendown()
for i in range(pn):
t.forward(n)
t.left(int(360/pn)) # 60도 만큼 터틀을 왼쪽으로 회전시킨다.
def draw_line(x, y, length):
t.penup()
t.goto(x,y)
t.pendown()
t.right(90)
t.forward(length)
t.left(90)
draw_line(0, 360, 600) # 가운데 정렬을 보이기 위함. 제거 하면 됨.
draw_circle(0, 300)
x = 0
y = 160
for i in range(6,2,-1):
draw_polygon(x, y, i)
y -= 130
turtle.done()
try:
turtle.bye()
except:
print("bye")
728x90
반응형
'프로그램' 카테고리의 다른 글
[C언어] 구구단 출력 (0) | 2023.05.02 |
---|---|
[C언어] 홀수를 입력 받아서 *로 정삼각형 찍기 (1) | 2023.05.02 |
[파이썬] 문제 : 가위,바위,보 게임 (0) | 2023.05.01 |
[파이썬] 문제 : 사용자 정보 파일로 관리 (0) | 2023.04.29 |
[C언어] 4진수 변환 (0) | 2023.04.29 |
댓글