Attributes

Here we see that the attributes of Car art defined by itg variables, which ate indented. We can use this class template to create car instances.

# create an instance of my car

# and display its attributes myCar = Car()

print "After Create:", myCar.color, myCar.make, myCar.model

# Set myCars attributes then display attributes myCar.color, myCar.make, myCar.model = "Red", "Ford", "Taurus" print "After set:", myCar.color, myCar.make, myCar.model

The output is

Was this article helpful?

0 0

Post a comment