본문 바로가기
프로그램/Python 1000제

Python 125제] 파이썬 EXPRESS CHAPTER 5. 도전문제 2) p232

by 건티 2023. 1. 12.
728x90

출처 : 반크_세계유산 경복궁

 

참고풀이]

import turtle
t=turtle.Turtle()
t.shape("turtle")

def square(length,N):
    t.down()
    for i in range(N):
        t.forward(length)
        t.left(360/N)
    t.up()


#MainPart
N=int(input("원하는 각형을 입력하시오 : "))
Colors=["blue","red","green", "yellow","black"]
t.up()
t.goto(-450,0)
for C in Colors:
    t.fillcolor(C)
    t.begin_fill()
    t.forward(120)
    square(100,N)
    t.end_fill()

turtle.mainloop()
#turtle.bye()

 

 

참고풀이 결과]

 

 

 

 

 

대한민국의 아름다운 영토, 독도의 봄

 

반응형

댓글