開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅲ.(Statements and Syntax)、Chapter 13.(while and for loop)、Test Your Knowledge: Quiz 1.を解いてみる。
その他参考書籍
- Pythonチュートリアル 第2版
- Python クックブック 第2版 (原書(最新版))
- Programming Python
- Python Pocket Reference (Pocket Reference (O'Reilly))
Test Your Knowledge: Quiz 1.
コード(BBEdit)
sample1.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# while loop は汎用的に、for loopはsequence, iterableで使うl = list(range(10))
# while loopはカウンターが必要。for loopはいらない。
print('while loop')
i = 0
while i < 10:
print(l[i])
i += 1
print('for loop')
for n in l:
print(n)
入出力結果(Terminal, IPython)
$ ./sample1.py while loop 0 1 2 3 4 5 6 7 8 9 for loop 0 1 2 3 4 5 6 7 8 9 $
0 コメント:
コメントを投稿