Litres per 100 km

Data with PythonEasy+10 XP+10

Litres per 100 km

A delivery van logs each trip: how many km it drove and how many litres of fuel it used. Drivers compare vans by litres per 100 km:

litres ÷ km × 100

Task: write fuel_per_100km(trips).

  • trips is a list of dictionaries, each with trip, km and litres. Turn it into a DataFrame.
  • Add a new column holding each trip's litres per 100 km.
  • Return that column as a list, in the original order, with every value rounded to 1 decimal place.

km is always more than 0, and there is always at least one trip.

Examples

trips = [{"trip": "T1", "km": 120, "litres": 9.6}, {"trip": "T2", "km": 80, "litres": 7.2}]
returns [8.0, 9.0]
trips = [{"trip": "A", "km": 250, "litres": 17.5}, {"trip": "B", "km": 40, "litres": 3.8}, {"trip": "C", "km": 310, "litres": 22.0}]
returns [7.0, 9.5, 7.1]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run