728x90
- 터틀 그래픽으로 네모 그림 그리기
import turtle
colors=["red","purple","blue","green","yellow","orange"]
t=turtle.Turtle()
turtle.bgcolor("black")
t.speed(0)
t.width(3)
length=10
while length<500:
t.fd(length) //t.forward(길이)
t.pencolor(colors[length%6])
t.rt(89) //t.right(몇도)
length+=5
- 터틀 그래픽으로 원형과 육각형 그리기
import turtle
t=turtle.Turtle()
t.fd(100)
t.lt(60)
t.fd(100)
t.lt(60)
t.fd(100)
t.lt(60)
t.fd(100)
t.lt(60)
t.fd(100)
t.lt(60)
t.fd(100)
t.circle(100) //t.circle(반지름)
연습문제
8. t.up() 펜을 드는(그려지지 않도록) 함수, t.down() 펜을 내려놓는 함수, goto(x,y)
거북이를 화면 좌표(x,y)이동 시키는 함수
import turtle
t=turtle.Turtle()
t.shape("turtle")
t.color("red")
t.width(5)
t.fd(200)
t.up()
t.goto(0,200)
t.down()
t.goto(200,200)
9. t.circle을 이용한 오륜기
import turtle
t=turtle.Turtle()
t.shape("turtle")
t.color("purple")
t.circle(100)
t.up()
t.goto(150,0)
t.down()
t.circle(100)
t.up()
t.goto(300,0)
t.down()
t.circle(100)
t.up()
t.goto(75,-150)
t.down()
t.circle(100)
t.up()
t.goto(225,-150)
t.down()
t.circle(100)
728x90
728x90
'파이썬-py' 카테고리의 다른 글
클래스, 모듈.py (0) | 2022.07.25 |
---|---|
사용자 입력과 출력.py (0) | 2022.07.25 |
함수.py (0) | 2022.07.25 |
제어문 <if문 while문 for문> (0) | 2022.07.21 |
파이썬 자료형&변수 (0) | 2022.07.21 |