티스토리 뷰

Test/Python(20220101~)

Days18. Turtle, GUI

kiostory 2022. 2. 19. 22:56

* 다각형 그리는 거북이 

 

from turtle import Turtle,Screen
timmy_the_turtle = Turtle()
timmy_the_turtle.shape("turtle")
timmy_the_turtle.color("red")
poly=int(input("Which polygon do you want to draw? (3,4,5,6,8,12,24,36,72 ...) :" ))
circle = 360
while circle > 0:
    timmy_the_turtle.forward(100)
    timmy_the_turtle.right(360/poly)
    circle -= 360/poly
screen = Screen()
screen.exitonclick()

 

Which polygon do you want to draw? (3,4,5,6,8,12,24,36,72 ...) :8

 

timmy_the_turtle.pu()
timmy_the_turtle.goto(-200,200)
for i in range(15):
    timmy_the_turtle.pd()
    timmy_the_turtle.fd(10)
    timmy_the_turtle.pu()
    timmy_the_turtle.fd(10)

'Test > Python(20220101~)' 카테고리의 다른 글

Days18. Turtle drawing Polygons  (0) 2022.02.20
Days18. Import module (모듈)  (0) 2022.02.20
Days17.퀴즈 프로젝트3  (0) 2022.02.18
Days17.퀴즈 프로젝트2  (0) 2022.02.15
Days17. 퀴즈 프로젝트  (0) 2022.02.14
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함