1. 눈사람 그리기
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.color("black", "white")
s = turtle.Screen(); s.bgcolor('skyblue');
def draw_snowman(x, y):
t.up()
t.goto(x, y)
t.down()
t.begin_fill()
t.circle(20)
t.end_fill()
t.goto(x, y-25)
t.setheading(135)
t.forward(50)
t.backward(50)
t.setheading(30)
t.forward(50)
t.backward(50)
t.setheading(0) #거북이 방향 오른쪽
t.begin_fill()
t.circle(15)
t.end_fill()
t.goto(x, y-70)
t.begin_fill()
t.circle(30)
t.end_fill()
draw_snowman(0, 0)
draw_snowman(100, 0)
draw_snowman(200, 0)
수학적 함수를 계산하는 함수를 작성
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.speed(0)
def f(x):
return x**2+1
t.goto(200, 0)
t.goto(0, 0)
t.goto(0, 200)
t.goto(0, 0)
for x in range(150):
t.goto(x, int(0.01*f(x)))
'Programing > Python' 카테고리의 다른 글
Python :: 리스트(list)와 딕셔너리(dictionary) - 연습문제 (0) | 2017.06.12 |
---|---|
Python :: 리스트(list)와 딕셔너리(dictionary) - 내용 (0) | 2017.06.12 |
Python :: 함수 - 내용 (0) | 2017.06.12 |
Python :: 파이썬에서 언더바(_) 하나의 뜻 (0) | 2017.06.12 |
Python :: 반복문 - 연습문제 (0) | 2017.06.11 |