Python Class
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 modified 3yr ago