runtime
256 / 500
question 256 Classes & Objects · medium

Temperature readings in the wrong unit

Weather stations report in Celsius or Fahrenheit, and Reading is meant to store every reading in Celsius so they can be compared. The charts show 41 °F stored as about 23 °C, some readings still say unit F, and stations that send a lower-case f are rejected. Fix Reading.__init__.

ClassReading(station, value, unit="C")
Storesstation; celsius, the value in Celsius rounded to 1 place (°C = (°F − 32) × 5 / 9); unit always "C"
unit"C" or "F" in either case; anything else raises ValueError

Loading your progress…

Temperature readings in the wrong unit — Python practice · Runtime