All Courses

Someone guide please.

By Sde221876gmailcom, a year ago
  • Bookmark
0

Someone guide please.

Code:

class vehicle:
    def __init__(self,name,color,max_speed,mileage):
        self.name = name
        self.color = "white"
        self.max_speed = max_speed
        self.mileage = mileage
class Bus(vehicle):
    pass
class Car(vehicle):
    pass
class Bike(vehicle):
    pass
obj = Bus("volvo",120,4)
obj1= Car("Wagnor",180,8)
obj2= Bike("pulsar",110,5)
print(f"Bus model name is {obj.name} with color {obj.color} and maximum speed is {obj.max_speed}")
print(f"Car model name is {obj1.name} with color {obj1.color} and maximum speed is {obj1.max_speed}")
print(f"Bike model name is {obj2.name} with color {obj2.color} and maximum speed is {obj2.max_speed}")

output:

TypeError                                 Traceback (most recent call last)
Cell In [2], line 14
     12 class Bike(vehicle):
     13     pass
---> 14 obj = Bus("volvo",120,4)
     15 obj1= Car("Wagnor",180,8)
     16 obj2= Bike("pulsar",110,5)

TypeError: vehicle.__init__() missing 1 required positional argument: 'mileage'


Python
Oops
Error
Typeerror
0 Answer
Your Answer

Webinars

More webinars

Related Discussions

Running random forest algorithm with one variable

View More