計算機科学のブログ

ほしい物リスト

Python - Diving in: Let's Make a Splash - string, int

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)、EXERCISE(177/682)の解答を求めてみる。

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

Average.ipynb

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