計算機科学のブログ

ほしい物リスト

Python - Lists of Numbers: Processing List Data - for loop

Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly GuidePaul Barry(著)、 O’Reilly Mediaの Chapter 3.(Lists of Numbers: Processing List Data)、EXERCISE(52/101)の解答を求めてみる。

Jupyter(コード、入出力結果)

Average.ipynb

for t in times:
    minutes, rest = t.split(':')
    seconds, hundredths = rest.split('.')
    converted_time = int(minutes) * 60 * 100 + int(seconds) * 100 + int(hundredths)
    print(t, converted_time)
1:27.95 8795
1:21.07 8107
1:30.96 9096
1:23.22 8322
1:27.95 8795
1:28.30 8830