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)