index

Besides list, tuple, string, dictionary, set are data structure, you can define class that has attributes

For example

class car(object):

wheel\_number=4

seal\_row\_number=2

def \_\_init\_\_\(self,brand\):

    self.brand=brand

wheel_number, seal_row_number are class attributes, class attributes can be of any data type, include

list, tuple, string, dictionary and set

You notice class can also have methods, __init__ is called constructor method, it runs when instantiating a class, for example

small_car=car("toyota")

small_car.brand

'toyota’

small_car.seal_row_number

2

Last updated