2014年5月12日月曜日

開発環境

Head First Programming A learner's guide to programming using the Python language (David Griffiths(著)、Paul Barry(著)、 O'Reilly Media; )のChapter 4(data in files and arrays: Sort it out)、Exercise(p.123)を解いてみる。

Exercise(p.123)

コード(BBEdit)

sample123,.py

#!/usr/bin/env python3
#-*- coding: utf-8

highest_score = 0
with open('results.txt') as result_f:
    for line in result_f:
        name, score = line.split()
        score = float(score)
        if score > highest_score:
            highest_score = score

print('The highest score was: {0}'.format(highest_score))

入出力結果(Terminal)

$ ./sample123.py
The highest score was: 9.12
$

0 コメント:

コメントを投稿