開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 3(Py Filling: Lists, Tuples, Dictionaries, and Sets)、Things to Do 3.4, 3.5, 3.6, 3.7.を解いてみる。
Things to Do 3.4, 3.5, 3.6, 3.7.
入出力結果(Terminal, IPython)
$ ipython Python 3.4.2 (default, Nov 1 2014, 16:32:22) Type "copyright", "credits" or "license" for more information. IPython 2.3.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: things = ['mozzarella', 'cinderella', 'salmonella'] In [2]: things Out[2]: ['mozzarella', 'cinderella', 'salmonella'] In [3]: things[1] = things[1].capitalize() In [4]: things Out[4]: ['mozzarella', 'Cinderella', 'salmonella'] In [5]: things[0] = things[0].upper() In [6]: things Out[6]: ['MOZZARELLA', 'Cinderella', 'salmonella'] In [7]: things.remove('salmonella') In [8]: things Out[8]: ['MOZZARELLA', 'Cinderella'] In [9]: things.append('salmonella') In [10]: things.pop() Out[10]: 'salmonella' In [11]: things Out[11]: ['MOZZARELLA', 'Cinderella'] In [12]: things.append('salmonella') In [13]: things.pop(-1) Out[13]: 'salmonella' In [14]: things Out[14]: ['MOZZARELLA', 'Cinderella'] In [15]: things.append('salmonella') In [16]: things.pop(2) Out[16]: 'salmonella' In [17]: things Out[17]: ['MOZZARELLA', 'Cinderella'] In [18]: things.append('salmonella') In [19]: del things[-1] In [20]: things Out[20]: ['MOZZARELLA', 'Cinderella'] In [21]: things.append('salmonella') In [22]: del things[2] In [23]: things Out[23]: ['MOZZARELLA', 'Cinderella'] In [24]: quit() $
0 コメント:
コメントを投稿