← Back to Home

Unit Details - Slides

Assessments

  • Only 3 labs are assessed
    • Rest are for practice

Object & Arrays in Python - Slides

Memory Model

See: Memory

Objects in Python

  • Python is an object-oriented language
    • Classes are the basis for all data types
      e.g. int, float, str are inbuilt classes
  • Given temperature = 98.6:
    • temperature-> reference to object

    • 98.6 -> object of class float

  • Now if we add original = temperature:
    • We create another reference (also called an alias) for this object

Class is the blueprint and object is a specific instance

Every class like float and int has methods that can be used to manipulate the values of the object

Constructor is a method to create an object of a specific class

  • i.e. instead of t = 98.6 -> we can write t = float(98.6)
  • Constructor has same name as class

If an object has no reference, it is unusable and in Python, a background program will clear the object from memory to free up space


CITS2200 - Lecture 2