A2.1 Lists and variables
Code stores data two ways: a variable holds one value; a list holds many in order. Processing means doing something with the stored data — adding to it, counting it, picking out one item, or running through it to find a total.
Example
Trace the program: what does each print line show, and how would you find the warmest reading?
- After the append, temps holds four readings; print count shows 4.
- Item 4 is the last one appended: 23.
Remember: Warmest: set a variable best to the first item, run through the list, and whenever an item is larger, set best to it; print best.
A2.2 Coding, technology and the trades
Example
Describe what stored data changes for a farmer and an HVAC technician.
- Farmer: soil sensors log moisture in a list, so watering runs only where the readings are low.
- HVAC technician: a controller stores each room's temperature, so the furnace runs less and faults show as odd readings.
Example
Describe what stored data changes for a nurse.
- Nurse: a monitor stores a patient's readings over the night, so a change is caught early. The data helps the judgement; it does not replace it.
Summary
- Variable: one value; list: many in order.
- Append, count, pick, run through.
- Stored data lets trades act on readings, not guesses.