開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART III.(Statements and Syntax)、Test Your Knowledge(Part III Exercises)、4-c.(Program logic alternatives)を解いてみる。
その他参考書籍
4-c.(Program logic alternatives)
コード(BBEdit)
sample.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
L = [1, 2, 4, 8, 16, 32, 64]
x = 5
i = 0
if 2 ** x in L:
print('at index', L.index(2 ** x))
else:
print(x, 'not found')
入出力結果(Terminal)
$ ./power.py at index 5 $
0 コメント:
コメントを投稿