開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅱ.(Types and Operations)、Chapter 4.(Introducing Python Object Types)、Test Your Knowledge: Quiz 6.を解いてみる。
その他参考書籍
Test Your Knowledge: Quiz 6.
コード(BBEdit)
sample6.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# + 演算子や * 演算子などがいろいろなtypeで使えるのはpolymorphismのおかげ
print(1 + 2)
print('python' + ' programmer')
print([1,2] + [3,4,5])
print((1, 2) + (3, 4, 5))
print(1.2 + 3.4)
print(1 + 1.2)
print(1 * 2)
print('python' * 2)
print([1,2] * 2)
print((1, 2) * 2)
print(1.2 * 2)
print(1.2 * 3.4)
print(1.2 * 1)
入出力結果(Terminal, IPython)
$ ./sample6.py 3 python programmer [1, 2, 3, 4, 5] (1, 2, 3, 4, 5) 4.6 2.2 2 pythonpython [1, 2, 1, 2] (1, 2, 1, 2) 2.4 4.08 1.2 $
0 コメント:
コメントを投稿