開発環境
- 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)、CHAPTER 10(Introducing Python Statements)、Test Your Knowledge: Quiz 4, 5, 6, 7, 8を解いてみる。
その他参考書籍
Quiz 4, 5, 6, 7, 8
コード(BBEdit)
sample.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# 4
a = [1, 2,
3, 4,
5]
b = 1 + 2 + \
3 + 4
c = (1 + 2 +
3 + 4)
d = (1, 2,
3, 4)
e = {1, 2,
3, 4}
f = {'a':1, 'b':2,
'c':3, 'd':4}
print(a, b, c, d, e, f, sep='\n')
# 5 6
print('Hello world!'); print('Hello python world!')
# 7
try:
print(1 / 0)
except Exception as err:
print(type(err), err, err.args)
# 8
def f():
print('Hello ":" world!')
f()
入出力結果(Terminal)
$ ./sample.py
[1, 2, 3, 4, 5]
10
10
(1, 2, 3, 4)
{1, 2, 3, 4}
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
$
0 コメント:
コメントを投稿