2015年7月18日土曜日

開発環境

  • OS X Yosemite - Apple (OS)
  • Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
  • Python 3.4 (プログラミング言語)

Python for Kids: A Playful Introduction to Programming (Jason R. Briggs (著) 、No Starch Press)のPart Ⅰ.(Learning to Program)、Chapter 8.(How to Use Classes and Objects)、Programming Puzzles #2: Turtle Pitchfork(No. 2030)を解いてみる。

Programming Puzzles #2: Turtle Pitchfork(No. 2030)

コード(Emacs, BBEdit)

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

import turtle

pen1 = turtle.Pen()
pen2 = turtle.Pen()
pen3 = turtle.Pen()
pen4 = turtle.Pen()

len1 = 60
len2 = 50
len3 = 20
len4 = 10
len5 = 40
len6 = 30

pen1.forward(len2)
pen1.left(90)
pen1.forward(len5)
pen1.right(90)
pen1.forward(len3)

pen2.forward(len2)
pen2.right(90)
pen2.forward(len5)
pen2.left(90)
pen2.forward(len3)

pen3.forward(len1)
pen3.left(90)
pen3.forward(len6)
pen3.right(90)
pen3.forward(len4)

pen4.forward(len1)
pen4.right(90)
pen4.forward(len6)
pen4.left(90)
pen4.forward(len4)
         
while True:
    pass

0 コメント:

コメントを投稿

Comments on Google+: