Practical Programming
An Introduction to Computer Science
Using Python 3
(Pragmatic Programmers)
(Pragmatic Bookshelf)
Paul Gries (著) Jennifer Campbell (著)
Jason Montojo (著) Lynn Beighley (編集)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 3(Designing and Using Functions)、3.11-2, a, b, c.を解いてみる。
3.11-2, a, b, c.
コード(BBEdit)
入出力結果(Terminal, IPython)
$ ipython Python 3.4.1 (default, May 21 2014, 01:39:38) Type "copyright", "credits" or "license" for more information. IPython 2.1.0 -- 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]: max(3, 4) Out[1]: 4 In [2]: abs(-5) Out[2]: 5 In [3]: min(4, 5) Out[3]: 4 In [4]: min(max(3, 4), abs(-5)) Out[4]: 4 In [5]: max(2, 8) Out[5]: 8 In [6]: min(4, 6, 8) Out[6]: 4 In [7]: abs(4) Out[7]: 4 In [8]: abs(min(4, 6, max(2, 8))) Out[8]: 4 In [9]: max(5.572, 3.258) Out[9]: 5.572 In [10]: abs(-2) Out[10]: 2 In [11]: round(5.572, 2) Out[11]: 5.57 In [12]: round(max(5.572, 3.258), abs(-2)) Out[12]: 5.57 In [13]: quit() $
0 コメント:
コメントを投稿