始める無料で始める

平均の移動時間

このデータセットで W20529 は 291 回の移動を行っています。平均すると、1 回の移動はどれくらいの長さでしょうか? この計算には、Python の組み込み関数 sum()len() を使えます。

前のコーディング演習に基づき、データは onebike_durations として読み込まれています。各要素は、その自転車がドックから外れていた秒数です。

この演習はコースの一部です

Pythonで扱う日付と時刻

コースを見る

演習の手順

  • onebike_durations に含まれるすべての移動について、total_elapsed_time(合計経過時間)を計算します。
  • onebike_durationsnumber_of_trips(移動回数)を計算します。
  • total_elapsed_timenumber_of_trips で割り、平均の移動時間を求めます。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# What was the total duration of all trips?
total_elapsed_time = ____(____)

# What was the total number of trips?
number_of_trips = ____(____)
  
# Divide the total duration by the number of trips
print(____ / ____)
コードを編集して実行