計算機科学のブログ

ほしい物リスト

Python - Diving in: Let's Make a Splash - list, append method, for loop

Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly GuidePaul Barry(著)、 O’Reilly Mediaの Chapter 2.(Diving in: Let’s Make a Splash)、SHARPEN YOUR PENCIL(183/682)の解答を求めてみる。

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

Average.ipynb

converts = []
for t in times:
    minutes, rest = t.split(':')
    seconds, hundredths = rest.split('.')
    converts.append(int(minutes) * 60 * 100 + int(seconds) * 100 + int(hundredths))
converts
[8795, 8107, 9096, 8322, 8795, 8830]