Readings summary
After every pass over the ground station, the engine team gets a summary of the temperature readings: the lowest, the highest and the average. Nobody reads five hundred numbers; everybody reads the summary.
Summarise the readings with Python's built-in functions, then make sure the summary survives a pass with no readings at all.
Finish stage 1 to unlock this stage.
Print the lowest and the highest reading, and the mean with one decimal place:
Min: 398.0 Max: 455.2 Mean: 419.5
min() and max() take the whole list. The mean is the sum of the readings divided by how many there are.
Finish stage 1 to unlock this stage.
Add the spread, the highest reading minus the lowest, with one decimal place. Then guard against a pass with no readings: an empty list would crash min() and the division. For an empty list, print only No readings.
Min: 398.0 Max: 455.2 Mean: 419.5 Spread: 57.2
Check len(readings) == 0 first, and move the summary under else.
Hints
Creating Lists
# Lists - ordered collections of items
# Square brackets, items separated by commas
planets = ["Mercury", "Venus", "Earth", "Mars"]
print("Inner planets:", planets)
# One list can hold different types at once
mission = ["Hail Mary", 3, True, 11.9]
print("Mission record:", mission)
# An empty list is still a list, ready to be filled later
sample_tubes = []
print("Samples collected:", sample_tubes)
# len() counts the items
crew = ["Grace", "Yao", "Ilyukhina"]
print("Crew size:", len(crew))
print("Tubes filled:", len(sample_tubes))
# The in operator checks membership
candidate_stars = ["Tau Ceti", "Epsilon Eridani", "Wolf 359", "Sirius"]
print("Stars checked:", len(candidate_stars))
if "Tau Ceti" in candidate_stars:
print("Tau Ceti is on the target list")
if "Betelgeuse" not in candidate_stars:
print("Betelgeuse is too far to bother")
Separate arguments with commas. They're passed on every Run as sys.argv[1:].