- 1

Create a python class called vehicle with 2 objects as follows

Create a python class called vehicle with 2 objects. Object 1 is a car with colour red cost rs 3 lakhs, object 2 is a Motorcycle with colour black and cost rs 1 lakhs.

27th Feb 2021, 2:23 PM
Himani Baro
Himani Baro - avatar
3 ответов
27th Feb 2021, 2:25 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
you need to advance a little bit in the Python Core course to start learning OOP (class) in Python ;) roughly, a (basic) class is defined by: class MyClassName: def __init__(self,model,color,cost): self.model = model self.color = color self.cost = cost and an object is instancied (created) by calling the class constructor: obj = MyClassName("boat","white",8) arguments are pased to __init__ magic method initializer, and instance is implicitly returned...
27th Feb 2021, 5:07 PM
visph
visph - avatar
0
Thank you so much
28th Feb 2021, 1:21 AM
Himani Baro
Himani Baro - avatar