開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Head First Python (Paul Barry(著)、 O'Reilly Media )のChapter 11(Dealing with Complexity: Data wrangling)、ANDROID POOL PUZZLE(p.427)を解いてみる。
ANDROID POOL PUZZLE(p.427)
コード(BBEdit, Emacs)
sample427.py
#-*- coding: utf-8 -*-
status_update(hello_message)
resp = do_dialog('Pick a distance', distances, app.dialogSetSingleChoiceItems)
if resp['which'] in ('positive'):
distance_run = app.dialogGetSelectedItems().result[0]
distance_run = distances[distance_run]
recorded_time = app.dialogGetInput('Enter a {0} time:'.format(distance_run),
'Use HH:MM:SS format:').result
closest_time = find_nearest_time(
format_time(recorded_time), row_ddata[distance_run])
closest_column_heading = row_data[distance_run][closest_time]
resp = do_dialog(
'Pick a distance to predict', distances, app.dialogSetSingleChoiceItems)
if resp['which'] in ('positive'):
predicted_distance = app.dialogGetSelectedItems().result[0]
predicted_distance = distances[predicted_distance]
prediction = [k for k in row_data[predicted_distance].keys()
if row_data[predicted_distance][k] \
== closest_column_heading]
do_dialog('The predicted time running {0} is: '.format(
predicted_distance), prediction, app.dialogSetItems,'OK', None)
status_update(quit_msg)
0 コメント:
コメントを投稿