開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs(Text Editor)
- プログラミング言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7)のIII部(ステートメント)のまとめ演習4.(プログラムを書き直す)を解いてみる。
その他参考書籍
4.(プログラムを書き直す)
コード(BBEdit)
sample.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- L = [2**x for x in range(7)] X = 5 if 2**X in L: print("at index {0}".format(L.index(2**X))) else: print("{0} not found".found(X))
入出力結果(Terminal)
$ ./sample.py at index 5 $
0 コメント:
コメントを投稿