開発環境
- 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-f.(Program logic alternatives)を解いてみる。
その他参考書籍
4-f.(Program logic alternatives)
コード(BBEdit)
sample.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
M = map(lambda x: 2 ** x, range(7))
print(M)
L = list(M)
print(L)
X = 5
i = 0
if 2 ** X in L:
print('at index', L.index(2 ** X))
else:
print(x, 'not found')
入出力結果(Terminal)
$ ./power.py <map object at 0x10951f050> [1, 2, 4, 8, 16, 32, 64] at index 5 $
0 コメント:
コメントを投稿