Editor

Sensor Day Summary

#603 · Working with data · Intermediate · Find and fix · 70 XP · about 10 min

A garden sensor records a temperature every hour, but sometimes it misses a reading, which is stored as None. day_summary(readings) should ignore the missing readings and return a tuple (low, high, average) of the real ones, with the average rounded to 1 decimal place. If there are no real readings at all, it returns None.

The code in the editor has two bugs. A reading of exactly 0 degrees is treated as missing, and the average comes out too low whenever a reading was missed.

Examples

day_summary([3, 5, 7])     # returns (3, 7, 5.0)
day_summary([4, None, 8])  # returns (4, 8, 6.0)
day_summary([0, 6])        # returns (0, 6, 3.0)
day_summary([None])        # returns None

Constraints

  • readings has 0 to 1,000 items, each a number from -50 to 50 or None.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.