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 9(Repeating Code Using Loops)、9.10(Exercises) 10.を解いてみる。
9.10(Exercises) 10.
コード(BBEdit)
sample10.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
for n in range(10, 0, -1):
print(n, end=' ')
print()
for n in sorted(range(1, 11), reverse=True):
print(n, end=' ')
print()
print(' '.join(list(map(lambda n: str(n), range(10, 0, -1)))))
入出力結果(Terminal, IPython)
$ ./sample10.py 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 $
0 コメント:
コメントを投稿