開発環境
- 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.(Functions and Generators)、Test Your Knowledge: Part IV Exercises 、2.(Arguments)を解いてみる。
その他参考書籍
2.(Arguments)
コード(BBEdit)
sample.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- def adder(x, y): return x + y for x, y in [('a', 'b'), ([1, 2], [3, 4]), (1.2, 3.4)]: print('{0} + {1} = {2}'.format(x, y, adder(x, y)))
入出力結果(Terminal)
$ ./sample.py a + b = ab [1, 2] + [3, 4] = [1, 2, 3, 4] 1.2 + 3.4 = 4.6 $
0 コメント:
コメントを投稿