2015年9月9日水曜日

開発環境

Python for Kids: A Playful Introduction to Programming (Jason R. Briggs (著) 、No Starch Press)のPart Ⅰ.(Learning to Program)、Chapter 11.(More Turtle Graphics)、Programming Puzzles #2: Drawing a Filled Octagon(No. 3099)を解いてみる。

Programming Puzzles #2: Drawing a Filled Octagon(No. 3099)

コード(Emacs)

#!/usr/bin/env python3
#-*- coding: utf-8 -*-

import turtle

t = turtle.Pen()

def octagon(size=100, filled=True):
    if filled:
        t.begin_fill()
    for x in range(8):
        t.forward(size)
        t.left(45)
    if filled:
        t.end_fill()

t.color(0.9, 0.75, 0)
octagon()
t.color(0,0,0)
octagon(filled=False)

while True:
    pass

入出力結果(Terminal, IPython)

$ ./sample2.py
  C-c C-cTraceback (most recent call last):
  File "./sample2.py", line 23, in <module>
    pass
KeyboardInterrupt
$

0 コメント:

コメントを投稿