본문 바로가기

파이썬 기초/파이썬

turtle

import turtle 로 화면을 띄운다. 

첫 실행화면 

한 줄씩 떼서보면, 

import turtle as t 

= turtle 이라는 모듈을 불러오고, turtle을 t로 정의해서 쓴다. 


t.forward(움직이고 싶은 픽셀길이) 

= 괄호 안에 넣은 숫자만큼 거북이가 움직인다. 

 

t.right(방향을 틀고 싶은 픽셀길이)

= 괄호 안에 넣은 숫자만큼 거북이가 방향을 움직인다. 


방향 함수들 

해당 함수들은 아래 주소에서 가져왔다. 

https://docs.python.org/3/library/turtle.html

 

turtle — Turtle graphics — Python 3.8.1 documentation

turtle — Turtle graphics Source code: Lib/turtle.py Introduction Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in

docs.python.org

 

원문(원래길이)의 함수와 줄임말이다. 줄임말을 써도 파이썬에서 읽을 수 있다. 

 

Turtle motionMove and draw

forward() | fd()

backward() | bk() | back()

right() | rt()

left() | lt()

goto() | setpos() | setposition()

setx()

sety()

setheading() | seth()

home()

circle()

dot()

stamp()

clearstamp()

clearstamps()

undo()

speed()

 

turtle — Turtle graphics — Python 3.8.1 documentation

turtle — Turtle graphics Source code: Lib/turtle.py Introduction Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in

docs.python.org

등등... 

 

'파이썬 기초 > 파이썬' 카테고리의 다른 글

배수처리  (0) 2020.02.05
중첩루프  (0) 2020.02.03
while  (0) 2020.02.02
for  (0) 2020.02.02
시퀀스 sequence - 2 (len,index,del)  (0) 2020.01.27