開始使用免費開始

平均行程時間

在這個資料集中,W20529 總共進行了 291 趟行程。平均每趟要花多久?你可以用 Python 內建的 sum()len() 來計算。

根據上一題的結果,資料已載入為 onebike_durations。每個元素代表這台單車離開停靠架的秒數。

本練習屬於課程

在 Python 處理日期與時間

檢視課程

練習說明

  • 計算 onebike_durations 中所有行程的 total_elapsed_time
  • 計算 onebike_durationsnumber_of_trips
  • total_elapsed_time 除以 number_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(____ / ____)
編輯並執行程式碼