Unit 4: Collections of Data

So far, each variable has held one value. What if you want to store 20 sensor readings? Or 100 scores? This unit introduces lists — Python’s way of storing an ordered collection of values in a single variable.

Lessons in This Unit

Lesson Title Key Concepts
Lesson 11 Introduction to Lists Creating lists, indexing, slicing, len(), iterating
Lesson 12 List Operations .append(), .remove(), .pop(), in, .sort(), sorted(), max/min/sum
Lesson 13 Ultrasonic Sensor and Sensor Logging HC-SR04 wiring, timing functions, storing sensor data

New Hardware: HC-SR04 Ultrasonic Distance Sensor

Measures distance using sound pulses — the same principle as bat echolocation! Range approximately 2cm to 400cm.

What You’ll Be Able to Do by the End

  • Create and access 1D lists by index
  • Add, remove, and search items in a list
  • Sort lists and find max/min/sum values
  • Wire and read an HC-SR04 ultrasonic distance sensor
  • Log multiple sensor readings into a list and analyse the data

Lists are one of the most useful data structures in all of programming. Once you understand them, you’ll use them constantly.


Copyright © Paul Baumgarten.