- 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.
3 Answers
+ 5
Where is your attempt?
https://www.sololearn.com/discuss/333866/?ref=app
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...
0
Thank you so much