Created
July 13, 2016 07:07
-
-
Save typosone/a69dafd8e35ce82b416189857ab99ef2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
def triangle(pen, size): | |
"""penを使用して一辺の長さsizeの正三角形を描きます""" | |
for a in range(3): | |
pen.forward(size) | |
pen.left(120) | |
def square(pen, size): | |
"""penを使用して一辺の長さsizeの正方形を描きます""" | |
for a in range(4): | |
pen.forward(size) | |
pen.left(90) | |
def move(pen, size): | |
"""\ | |
線を描かずにsize分前進します。 | |
移動後は線が描ける状態にします""" | |
pen.up() | |
pen.forward(size) | |
pen.down() | |
def house(pen, size): | |
"""\ | |
家(正方形の上に正三角形)を描きます。 | |
描き終わったら最初の場所まで戻ります。""" | |
square(pen, size) | |
pen.left(90) | |
move(pen, size) | |
pen.right(90) | |
triangle(pen, size) | |
pen.right(90) | |
move(pen, size) | |
pen.left(90) | |
t = turtle.Pen() | |
# 初期位置調整 | |
t.left(180) | |
move(t, 200) | |
t.right(180) | |
house(t, 100) | |
move(t, 150) | |
house(t, 200) | |
turtle.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment