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 4(Working with Text)、4.7(Exercises) 5-a, b, c, d, e.を解いてみる。
4.7(Exercises) 5-a, b, c, d, e.
コード(BBEdit)
sample5.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- x = 3 y = 12.5 print('The rabbit is {0}.'.format(x)) print('The rabbit is {0} years old.'.format(x)) print('{0} is average.'.format(y)) print('{0}*{1}'.format(y, x)) print('{0}*{1} is {2}'.format(y, x, y * x))
入出力結果(Terminal, IPython)
$ ./sample5.py The rabbit is 3. The rabbit is 3 years old. 12.5 is average. 12.5*3 12.5*3 is 37.5 $
0 コメント:
コメントを投稿