開発環境
- 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 2.を解いてみる。
その他参考書籍
- Pythonチュートリアル 第2版
- Python クックブック 第2版 (原書(最新版))
- Programming Python
- Python Pocket Reference (Pocket Reference (O'Reilly))
Test Your Knowledge: Quiz 2.
コード(BBEdit)
sample2.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# breakとcontinueで同じことをしてみる
print('break')
i = 0
while i < 100:
i += 1
print(i)
if i >= 10:
break
print('continue')
i = 0
while i < 100:
i += 1
if i > 10:
continue
print(i)
入出力結果(Terminal, IPython)
$ ./sample2.py break 1 2 3 4 5 6 7 8 9 10 continue 1 2 3 4 5 6 7 8 9 10 $
0 コメント:
コメントを投稿