메인
home
소프트웨어
home
📥

9강. 파이썬 터틀 라이브러리 함수 기초

파이썬 라이브러리란?

터틀 라이브러리 : 교육용 그림그리기 함수들 모음집

라이브러리를 가져오는 첫번째 방법 : import로 가져온다.

두번째 방법 : as로 별칭을 불러서 가져온다.

세번째 방법 : from 방식으로 기본함수로 등록해 준다.

윈도우 마크 그리기

from turtle import * bgcolor("black") width(5)= ["green", "yellow", "red", "blue"] for kk in range(4) : color([kk]) begin_fill() for ii in range(4) : fd(100) left(90) end_fill() penup() right(90) fd(30) pendown()
JavaScript
복사

랜던 물방울 그리기

from turtle import * import random as rd speed(20) colormode(255) for ii in range(100) : x = rd.randint(-100, 100) y = rd.randint(-500, 500) r = rd.randint(150, 255) g = rd.randint(150, 255) b = rd.randint(150, 255) k = rd.randint(20, 80) penup() goto(x, y) pendown() color(r, g, b) begin_fill() circle(k) end_fill()
Python
복사