2014年3月21日金曜日

開発環境

Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART III.(Functions and Generators)、Test Your Knowledge: Part IV Exercises 、1.(The basics.)を解いてみる。

その他参考書籍

1.(The basics.)

入出力結果(Terminal)

$ python3
Python 3.3.5 (default, Mar 15 2014, 14:51:54) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def func(x):
...     print(x)
... 
>>> func('Hello, python!')
Hello, python!
>>> func(10)
10
>>> func([1,2,3,4,5])
[1, 2, 3, 4, 5]
>>> func({'a':1, 'b':2, 'c':3, 'd':4, 'e':5})
{'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4}
>>> func()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: func() missing 1 required positional argument: 'x'
>>> func(1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: func() takes 1 positional argument but 2 were given
>>> quit()
$

0 コメント:

コメントを投稿