Practical Programming
An Introduction to Computer Science
Using Python 3
(Pragmatic Programmers)
(Pragmatic Bookshelf)
Paul Gries (著) Jennifer Campbell (著)
Jason Montojo (著) Lynn Beighley (編集)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 9(Repeating Code Using Loops)、9.10(Exercises) 15.を解いてみる。
9.10(Exercises) 15.
コード(BBEdit)
sample15.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
print('13.')
i = 1
while i <= 7:
print('T' * i)
i += 1
print('14.')
i = 6
while i >= 0:
print('{0}{1}'.format(' '* i, 'T' * (7 - i)))
i -= 1
入出力結果(Terminal, IPython)
$ ./sample15.py
13.
T
TT
TTT
TTTT
TTTTT
TTTTTT
TTTTTTT
14.
T
TT
TTT
TTTT
TTTTT
TTTTTT
TTTTTTT
$
0 コメント:
コメントを投稿