2014年12月11日木曜日

開発環境

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.8, 3.9.を解いてみる。

Things to Do 3.8, 3.9.

入出力結果(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]: surprise = ['Groucho', 'Chico', 'Harpo']

In [2]: surprise
Out[2]: ['Groucho', 'Chico', 'Harpo']

In [3]: surprise[-1] = surprise[-1].lower()

In [4]: surprise
Out[4]: ['Groucho', 'Chico', 'harpo']

In [5]: surprise[-1] = surprise[-1][::-1]

In [6]: surprise
Out[6]: ['Groucho', 'Chico', 'oprah']

In [7]: surprise[-1] = surprise[-1].capitalize()

In [8]: surprise
Out[8]: ['Groucho', 'Chico', 'Oprah']

In [9]: surprise = ['Groucho', 'Chico', 'Harpo']

In [10]: surprise[-1] = surprise[-1].lower()[::-1].capitalize()

In [11]: surprise
Out[11]: ['Groucho', 'Chico', 'Oprah']

In [12]: quit()
$

0 コメント:

コメントを投稿