Session 5 – Data retrieval and advanced object functions

  1. Concepts
    1. Objects
    2. Data retrieval/searching
    3. Advanced I/O
  2. Background/Overview
    1. Basic understanding of objects,I/O, and loops/conditionals.
  3. Lesson Plan
    1. Create data structure
      1. Create list and populate it with objects from input file
    2. Search data structure
      1. Find the object with the highest attribute
    3. Call methods on objects in list
      1. Method changes attributes of objects
      2. Search again for changed objects
  4. Activities
    1. class Car:
      def __init__(self, color, make, model, speed, owner):
      self.color = color
      self.make = make
      self.model = model
      self.speed = speed
      self.owner = owner

      def accelerate(self):
      self.speed = self.speed + 5

      def stop(self):
      self.speed = 0

      def __repr__(self):
      return self.owner + ' owns a ' + self.color + ' ' + self.make + ' ' + \
      self.model + ' traveling at ' + self.speed.__str__() + ' mph'