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 8(Storing Collections of Data Using Lists)、8.9(Exercises) 6-a, b, c, d.を解いてみる。
8.9(Exercises) 6-a, b, c, d.
コード(BBEdit)
sample6.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
print('a.')
temps = [25.2, 16.8, 31.4, 23.9, 28, 22.5, 19.6]
print(temps)
print('b.')
temps.sort()
print(temps)
print('c.')
cool_temps = temps[:2]
warm_temps = temps[2:]
print(cool_temps)
print(warm_temps)
print('d.')
temps_in_celsius = cool_temps + warm_temps
print(temps_in_celsius)
入出力結果(Terminal, IPython)
$ ./sample6.py a. [25.2, 16.8, 31.4, 23.9, 28, 22.5, 19.6] b. [16.8, 19.6, 22.5, 23.9, 25.2, 28, 31.4] c. [16.8, 19.6] [22.5, 23.9, 25.2, 28, 31.4] d. [16.8, 19.6, 22.5, 23.9, 25.2, 28, 31.4] $
0 コメント:
コメントを投稿